Compare commits

...

29 Commits

Author SHA1 Message Date
Michael Pfaff 9956b24eb2 Take GlobalKey<NavigatorState> instead of BuildContext 2020-04-24 14:16:22 -04:00
Michael Pfaff 45949890cc Make route handler constant 2020-04-20 16:59:39 -04:00
Michael Pfaff 8e99c535bd Remove file that should not be checked into version control 2020-04-20 16:59:23 -04:00
Luke 30ae4378df
Remove upper bounds on pubspec (#163)
* remove upper constraint for flutter environment
* update docs
Co-authored-by: Luke Pighetti <lukepighetti@gmail.com>
2020-04-07 10:46:20 -07:00
Luke Freeman 937afe9757 update docs 2020-03-28 14:37:43 -07:00
Luke Pighetti aca29a1e34
Allow Flutter <1.17.0 (#153)
- Support dev version
2020-03-22 14:56:55 -07:00
Luke Freeman 337d864b62 bump version 2020-03-08 19:54:50 -07:00
Luke Freeman 3a1a20e03b update CHANGLOG and README 2020-03-08 19:54:38 -07:00
Luke Freeman 53e1c97960 downgrade Flutter required version 2020-03-08 19:53:28 -07:00
Luke Freeman 16b09f760c bump version 2020-03-08 19:42:31 -07:00
Luke Freeman 624626c85d update README and CHANGELOG 2020-03-08 19:39:52 -07:00
Luke Freeman 2c06f63e19 bump to 1.6.0. fix compatibility issue 2020-02-10 17:28:31 -08:00
Luke Freeman 2676006fe3 update pubspec 2020-02-10 16:53:12 -08:00
Luke Freeman df3434d599 release prep 2020-02-10 16:51:30 -08:00
Luke Freeman fd792404d3 update podspec 2020-02-08 15:03:47 -08:00
Luke Freeman 827ecfcc65 update ios build artifacts 2020-02-08 15:03:22 -08:00
Yusuke Otsuka 5cce0a4db2
remove dart:io import (#132) 2020-02-08 08:36:48 -08:00
Luke Freeman 9a3ad8d03f fix example and migrate to androidx 2020-02-08 08:34:09 -08:00
Luke 1536372360 Update issue templates 2019-08-15 13:20:22 -07:00
Luke Freeman ddb81a6b29 fix transition bug. add explicit material transition type. tidy example. add font license. remove 'new', 'const', etc where not needed. 2019-07-17 20:19:56 -07:00
Luke Freeman 3d5a90de0d added cupertino native transition check. bump docs. prepare for release. 2019-06-20 09:28:28 +10:00
Miolin bf5de991ad Added transitions with CupertinoPageRoute (#103)
* #100, #85 added Cupertino transition type
* #100, #85 added CupertinoPageRoute
added support swipe to back with using CupertinoPageRoute
* added Cupertino full screen dialog transition type
* added Cupertino full screen dialog transition
2019-05-20 08:52:37 -07:00
Luke Freeman d3b3470ac2 fix deprecation warnings in example 2019-01-24 09:27:12 -08:00
Luke Freeman daf1742145 1.4.0 release 2018-12-21 10:16:09 -08:00
Jon Samwell a11dd62910 Added ability to define transition type when defining route (#63)
* Added ability to define transition type when defining route
* fixes to allow transition overrides. make route transition type optional (non-positional) and null by default. other fixes. NEEDS TESTING
* formatting changes
* fixed typo
2018-12-13 13:53:54 -08:00
Luke Freeman 79e35c5768 add toString to custom exception type 2018-10-25 11:03:20 -07:00
Luke Freeman 7ec4b2ed0a fix error return type. update licenses. 2018-10-25 10:48:02 -07:00
Luke Freeman b39baf4b8c formatting 2018-10-08 16:32:05 -07:00
Luke Freeman a1de0f6283 add pop convenience. add clearStack to clear history when pushing. 2018-10-08 16:31:10 -07:00
42 changed files with 661 additions and 265 deletions

38
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

View File

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@ -0,0 +1,18 @@
---
name: I need help using this library or have a question
about: Please, strongly consider posting your question to Stack Overflow or another
place. The purpose of this issue tracker is to track bugs and feature requests.
title: ''
labels: question, stack overflow
assignees: ''
---
Please, strongly consider posting your question to Stack Overflow. The purpose of this issue tracker is to track bugs and feature requests. Questions on how to use the library should be posted to stack overflow so that everyone can benefit from your question.
If you really need to post your question here:
1. Please be super clear on what you're trying to achieve. What is the expected result?
2. Please outline what you've tried. There is no point us suggesting something you've already tried.
3. Outline the things that have failed, based on your past attempts. This will help us to diagnose whether we need to add a feature or whether it is a bug.
Thanks!

4
.gitignore vendored
View File

@ -10,3 +10,7 @@ pubspec.lock
coverage
__temp_coverage*
.dart_tool/
build/
# iOS
**/flutter_export_environment.sh

View File

@ -1,3 +1,46 @@
# 1.6.3
- Remove upper bounds on Flutter SDK checks because Flutter releases are a ridiculous mess
# 1.6.2
- Support for Flutter `>=1.12 <=1.17`
# 1.6.1
- Support for Flutter `1.12+`
# 1.6.0
- No changes other than fixes for non-backwards compatible Flutter changes
- Flutter `>= 1.12.0` is required due to Flutter compatibility issues
- Dart `>= 2.6.0` is required
# 1.5.2
- Remove dependency on `dart:io`
- 1.5.x and lower now only supports Flutter versions `< 1.13.0`
# 1.5.1
- Add explicit material and full screen material transition types
- Fix issue in transition logic
- Remove redundant `new`, `const`, etc qualifiers
- Tidy example
- Add font license info
# 1.5.0
- Native transitions will now use the Cupertino page route on iOS and Material page route on android. This will enable swipe gestures on iOS.
- Added cupertino specific transition types.
- **You should not be using Cupertino types on non-iOS platforms. It's up to you, but it's bad design**.
# 1.4.0
- Added the ability to define a transition at the point of route definition. Route transitions are optional and any transition defined a "push" will override the route definition.
# 1.3.7
- Add `toString` for custom `RouteNotFoundException` type
# 1.3.6
- Small fix to error return type when no route match was made
# 1.3.5
- add `pop` convenience
- add `clearStack` flag so that you can clear the history when pushing a route
# 1.3.4
- Change lower dart version to cater to older flutter versions

16
LICENSE
View File

@ -1,9 +1,9 @@
Fluro
Created by Posse in NYC
http://goposse.com
Created by Yakka
https://theyakka.com
Copyright (c) 2017 Posse Productions LLC.
Copyright (c) 2019 Yakka LLC.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -14,17 +14,17 @@ modification, are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Posse Productions LLC, Posse nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
* Neither the name of the Yakka LLC, Yakka nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL POSSE PRODUCTIONS LLC (POSSE) BE LIABLE FOR ANY
DISCLAIMED. IN NO EVENT SHALL YAKKA LLC (YAKKA) BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -3,10 +3,12 @@
The brightest, hippest, coolest router for Flutter.
[![Version](https://img.shields.io/badge/version-1.3.4-blue.svg)](https://pub.dartlang.org/packages/fluro)
[![Version](https://img.shields.io/badge/version-1.6.3-blue.svg)](https://pub.dartlang.org/packages/fluro)
[![Build Status](https://travis-ci.org/theyakka/fluro.svg?branch=master)](https://travis-ci.org/theyakka/fluro)
[![Coverage](https://codecov.io/gh/theyakka/fluro/branch/master/graph/badge.svg)](https://codecov.io/gh/theyakka/fluro)
Version `1.6.0` (and higher) requires Flutter `>= 1.12.0` and Dart `>= 2.6.0`. If you're running an older version of Flutter, use a version `< 1.6.0`.
## Features
- Simple route navigation
@ -25,7 +27,7 @@ See CHANGELOG for all breaking (and non-breaking) changes.
You should ensure that you add the router as a dependency in your flutter project.
```yaml
dependencies:
fluro: "^1.3.4"
fluro: "^1.6.3"
```
You can also reference the git repo directly if you want:
@ -59,6 +61,9 @@ var usersHandler = Handler(handlerFunc: (BuildContext context, Map<String, dynam
void defineRoutes(Router router) {
router.define("/users/:id", handler: usersHandler);
// it is also possible to define the route transition to use
// router.define("users/:id", handler: usersHandler, transitionType: TransitionType.inFromLeft);
}
```

View File

@ -1,19 +1,18 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "../config.gradle"
apply from: "../flutter.gradle"
android {
compileSdkVersion versions.targetSDK
buildToolsVersion "${versions.buildTools}"
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
minSdkVersion versions.minSDK
targetSdkVersion versions.targetSDK
applicationId "$appInfo.applicationID"
versionCode appInfo.build
versionName "${appInfo.version}"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion 24
targetSdkVersion 29
applicationId "app.yakka.fluroexample"
versionCode 1
versionName "1.6.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
@ -28,15 +27,15 @@ android {
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.jar'])
// kotlin
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61"
// google
compile "com.android.support:appcompat-v7:${versions.googleSupport}"
compile "com.android.support:support-v13:${versions.googleSupport}"
compile "com.android.support:support-v4:${versions.googleSupport}"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
// testing
androidTestCompile "com.android.support:support-annotations:${versions.googleSupport}"
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test:rules:1.0.1'
androidTestImplementation 'androidx.annotation:annotation:1.1.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:rules:1.2.0'
}

View File

@ -9,7 +9,7 @@ import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity : FlutterActivity() {
private val LOG_TAG = "A:Main"
private val logTag = "A:Main"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -17,16 +17,13 @@ class MainActivity : FlutterActivity() {
checkForLinkEvent(intent)
}
override fun onResume() {
super.onResume()
}
private fun checkForLinkEvent(intent: Intent) {
if (intent.action == Intent.ACTION_VIEW && intent.data != null) {
val path = intent.data.getQueryParameter("path")
val text = intent.data.getQueryParameter("message") ?: "Why you don't enter text?"
val data = intent.data
if (intent.action == Intent.ACTION_VIEW && data != null) {
val path = data.getQueryParameter("path")
val text = data.getQueryParameter("message") ?: "Why you don't enter text?"
if (path != null) {
Log.d(LOG_TAG, "Setting initial route to: $path?message=$text")
Log.d(logTag, "Setting initial route to: $path?message=$text")
flutterView.setInitialRoute("$path?message=$text")
}
}

View File

@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.2.30'
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

View File

@ -1,13 +1,13 @@
ext.appInfo = [
version: '1.3.0',
version: '1.6.0',
build: 1,
applicationID: "com.goposse.fluro"
]
ext.versions = [
minSDK: 21,
targetSDK: 27,
buildTools: '27.0.3',
kotlin: '1.2.30',
targetSDK: 29,
buildTools: '29.0.3',
kotlin: '1.3.61',
googleSupport: '27.1.0'
]

View File

@ -1 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true

View File

@ -0,0 +1,93 @@
Copyright 2015 SUNRISE DIGITAL, Juan Hodgson Authors (srdigital@msn.com)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 978 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 882 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 978 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

View File

@ -0,0 +1,18 @@
#
# NOTE: This podspec is NOT to be published. It is only used as a local source!
#
Pod::Spec.new do |s|
s.name = 'Flutter'
s.version = '1.0.0'
s.summary = 'High-performance, high-fidelity mobile apps.'
s.description = <<-DESC
Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS.
DESC
s.homepage = 'https://flutter.io'
s.license = { :type => 'MIT' }
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.vendored_frameworks = 'Flutter.framework'
end

View File

@ -8,7 +8,6 @@
/* Begin PBXBuildFile section */
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
41FA87031F2620DA005CDA4D /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 41FA87021F2620DA005CDA4D /* GeneratedPluginRegistrant.m */; };
@ -40,7 +39,6 @@
/* Begin PBXFileReference section */
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
41FA87011F2620DA005CDA4D /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
41FA87021F2620DA005CDA4D /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
@ -76,7 +74,6 @@
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
@ -190,7 +187,6 @@
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,

View File

@ -7,8 +7,11 @@
#import <Flutter/Flutter.h>
NS_ASSUME_NONNULL_BEGIN
@interface GeneratedPluginRegistrant : NSObject
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry;
@end
NS_ASSUME_NONNULL_END
#endif /* GeneratedPluginRegistrant_h */

View File

@ -1,39 +1,43 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import '../../config/application.dart';
import 'package:flutter/material.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import '../../config/application.dart';
import '../../config/routes.dart';
class AppComponent extends StatefulWidget {
@override
State createState() {
return new AppComponentState();
return AppComponentState();
}
}
class AppComponentState extends State<AppComponent> {
AppComponentState() {
final router = new Router();
final router = Router();
Routes.configureRoutes(router);
Application.router = router;
}
@override
Widget build(BuildContext context) {
final app = new MaterialApp(
final app = MaterialApp(
title: 'Fluro',
theme: new ThemeData(
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
onGenerateRoute: Application.router.generator,
navigatorKey: Application.routerKey,
);
print("initial route = ${app.initialRoute}");
// print("initial route = ${app.initialRoute}");
return app;
}
}

View File

@ -1,8 +1,9 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import 'package:flutter/material.dart';
@ -16,15 +17,16 @@ class DemoMessageComponent extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Material(
return Material(
color: this.color,
child: new Center(
child: new Text(
message,
style: new TextStyle(
fontFamily: "Lazer84",
child: Center(
child: Text(
message,
style: TextStyle(
fontFamily: "Lazer84",
),
),
)),
),
);
}
}

View File

@ -1,13 +1,21 @@
/*
* fluro
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import 'package:flutter/material.dart';
class DemoResultComponent extends StatefulWidget {
@override
_DemoResultComponentState createState() => new _DemoResultComponentState();
_DemoResultComponentState createState() => _DemoResultComponentState();
}
class _DemoResultComponentState extends State<DemoResultComponent> {
@override
Widget build(BuildContext context) {
return new Container();
return Container();
}
}

View File

@ -1,8 +1,9 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import '../../helpers/color_helpers.dart';
@ -23,32 +24,32 @@ class DemoSimpleComponent extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Material(
return Material(
color: color,
child: new Column(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
new Image(
image: new AssetImage("assets/images/acc_boom.png"),
Image(
image: AssetImage("assets/images/acc_boom.png"),
color: ColorHelpers.blackOrWhiteContrastColor(color),
width: 260.0,
),
new Padding(
padding: new EdgeInsets.only(left: 50.0, right: 50.0, top: 15.0),
child: new Text(
Padding(
padding: EdgeInsets.only(left: 50.0, right: 50.0, top: 15.0),
child: Text(
message,
textAlign: TextAlign.center,
style: new TextStyle(
style: TextStyle(
color: ColorHelpers.blackOrWhiteContrastColor(color),
height: 2.0,
),
),
),
new Padding(
padding: new EdgeInsets.only(top: 15.0),
child: new ConstrainedBox(
constraints: new BoxConstraints(minHeight: 42.0),
child: new FlatButton(
Padding(
padding: EdgeInsets.only(top: 15.0),
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: 42.0),
child: FlatButton(
highlightColor:
ColorHelpers.blackOrWhiteContrastColor(color).withAlpha(17),
splashColor:
@ -60,9 +61,9 @@ class DemoSimpleComponent extends StatelessWidget {
Navigator.pop(context, result);
}
},
child: new Text(
child: Text(
"OK",
style: new TextStyle(
style: TextStyle(
fontSize: 18.0,
color: ColorHelpers.blackOrWhiteContrastColor(color),
),

View File

@ -1,20 +1,23 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import 'dart:async';
import '../../config/application.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../config/application.dart';
class HomeComponent extends StatefulWidget {
@override
State createState() => new HomeComponentState();
State createState() => HomeComponentState();
}
class HomeComponentState extends State<HomeComponent> {
@ -32,16 +35,16 @@ class HomeComponentState extends State<HomeComponent> {
];
Widget deepLinkWidget(BuildContext context) {
return new Stack(
return Stack(
children: <Widget>[
// copied widget
new AnimatedOpacity(
AnimatedOpacity(
opacity: (_deepLinkOpacity - 1.0).abs(),
duration: new Duration(milliseconds: 400),
child: new Center(
child: new Text(
duration: Duration(milliseconds: 400),
child: Center(
child: Text(
"Copied to clipboard!",
style: new TextStyle(
style: TextStyle(
fontSize: 14.0,
color: const Color(0xFFFFFFFF),
fontWeight: FontWeight.w500,
@ -50,16 +53,16 @@ class HomeComponentState extends State<HomeComponent> {
),
),
// button widget
new AnimatedOpacity(
AnimatedOpacity(
opacity: _deepLinkOpacity,
duration: new Duration(milliseconds: 250),
child: new Center(
child: new FlatButton(
duration: Duration(milliseconds: 250),
child: Center(
child: FlatButton(
highlightColor: const Color(0x11FFFFFF),
splashColor: const Color(0x22FFFFFF),
onPressed: () {
if (_deepLinkOpacity == 1.0) {
new Timer(new Duration(milliseconds: 2000), () {
Timer(Duration(milliseconds: 2000), () {
setState(() {
_deepLinkOpacity = 1.0;
});
@ -67,16 +70,16 @@ class HomeComponentState extends State<HomeComponent> {
setState(() {
_deepLinkOpacity = 0.0;
});
final clipboardData = new ClipboardData(text: _deepLinkURL);
final clipboardData = ClipboardData(text: _deepLinkURL);
Clipboard.setData(clipboardData);
}
},
child: new Padding(
padding: new EdgeInsets.all(8.0),
child: new Text(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
"Click here to copy a deep link url to the clipboard",
textAlign: TextAlign.center,
style: new TextStyle(
style: TextStyle(
fontSize: 12.0,
color: const Color(0xCCFFFFFF),
),
@ -92,52 +95,99 @@ class HomeComponentState extends State<HomeComponent> {
@override
Widget build(BuildContext context) {
var menuWidgets = <Widget>[
new Padding(
padding: new EdgeInsets.only(bottom: 35.0),
child: new Image(
image: new AssetImage("assets/images/logo_fluro.png"),
width: 200.0),
),
menuButton(context, "Native Animation", "native"),
menuButton(context, "Preset (In from Left)", "preset-from-left"),
menuButton(context, "Preset (Fade In)", "preset-fade"),
menuButton(context, "Custom Transition", "custom"),
menuButton(context, "Navigator Result", "pop-result"),
menuButton(context, "Function Call", "function-call"),
new Padding(
padding: new EdgeInsets.only(top: 65.0, left: 60.0, right: 60.0),
child: new Center(
child: new ConstrainedBox(
constraints: new BoxConstraints.tightFor(height: 60.0),
child: deepLinkWidget(context),
),
),
),
menuButton(context, 'assets/images/ic_transform_native_hz.png',
"Native Animation", "native"),
menuButton(context, 'assets/images/ic_transform_fade_in_hz.png',
"Preset (Fade In)", "preset-fade"),
menuButton(context, 'assets/images/ic_transform_global_hz.png',
"Preset (Global transition)", "fixed-trans"),
menuButton(context, 'assets/images/ic_transform_custom_hz.png',
"Custom Transition", "custom"),
menuButton(context, 'assets/images/ic_result_hz.png', "Navigator Result",
"pop-result"),
menuButton(context, 'assets/images/ic_function_hz.png', "Function Call",
"function-call"),
];
return new Material(
final size = MediaQuery.of(context).size;
final childRatio = (size.width / size.height) * 2.5;
return Material(
color: const Color(0xFF00D6F7),
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: menuWidgets,
child: SafeArea(
top: true,
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 25, bottom: 35, left: 25),
child: Image(
image: AssetImage("assets/images/logo_fluro.png"),
width: 100.0,
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25),
child: GridView.count(
childAspectRatio: childRatio,
crossAxisCount: 2,
mainAxisSpacing: 5,
children: menuWidgets,
),
),
),
// Padding(
// padding: EdgeInsets.only(top: 35.0, bottom: 25),
// child: Center(
// child: ConstrainedBox(
// constraints: BoxConstraints.tightFor(height: 60.0),
// child: deepLinkWidget(context),
// ),
// ),
// ),
],
),
),
);
}
// helpers
Widget menuButton(BuildContext context, String title, String key) {
return new Padding(
padding: new EdgeInsets.all(4.0),
child: new ConstrainedBox(
constraints: new BoxConstraints(minHeight: 42.0),
child: new FlatButton(
Widget menuButton(
BuildContext context, String assetSrc, String title, String key) {
return Padding(
padding: EdgeInsets.all(4.0),
child: Container(
height: 42.0,
child: FlatButton(
color: const Color(0x22FFFFFF),
highlightColor: const Color(0x11FFFFFF),
splashColor: const Color(0x22FFFFFF),
child: new Text(
title,
style: new TextStyle(
color: const Color(0xAA001133),
),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Container(
height: 36,
child: Image.asset(
assetSrc,
fit: BoxFit.contain,
),
),
),
Text(
title,
textAlign: TextAlign.center,
style: TextStyle(
color: const Color(0xAA001133),
),
)
],
),
onPressed: () {
tappedMenuButton(context, key);
@ -153,7 +203,7 @@ class HomeComponentState extends State<HomeComponent> {
String hexCode = "#FFFFFF";
String result;
TransitionType transitionType = TransitionType.native;
if (key != "custom" && key != "function-call") {
if (key != "custom" && key != "function-call" && key != "fixed-trans") {
if (key == "native") {
hexCode = "#F76F00";
message =
@ -172,7 +222,7 @@ class HomeComponentState extends State<HomeComponent> {
hexCode = "#7d41f4";
message =
"When you close this screen you should see the current day of the week";
result = "Today is ${_daysOfWeek[new DateTime.now().weekday - 1]}!";
result = "Today is ${_daysOfWeek[DateTime.now().weekday - 1]}!";
}
String route = "/demo?message=$message&color_hex=$hexCode";
@ -182,10 +232,10 @@ class HomeComponentState extends State<HomeComponent> {
}
Application.router
.navigateTo(context, route, transition: transitionType)
.navigateTo(Application.routerKey, route, transition: transitionType)
.then((result) {
if (key == "pop-result") {
Application.router.navigateTo(context, "/demo/func?message=$result");
Application.router.navigateTo(Application.routerKey, "/demo/func?message=$result");
}
});
} else if (key == "custom") {
@ -194,24 +244,27 @@ class HomeComponentState extends State<HomeComponent> {
"This screen should have appeared with a crazy custom transition";
var transition = (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
return new ScaleTransition(
return ScaleTransition(
scale: animation,
child: new RotationTransition(
child: RotationTransition(
turns: animation,
child: child,
),
);
};
Application.router.navigateTo(
context,
Application.routerKey,
"/demo?message=$message&color_hex=$hexCode",
transition: TransitionType.custom,
transitionBuilder: transition,
transitionDuration: const Duration(milliseconds: 600),
);
} else if (key == "fixed-trans") {
Application.router.navigateTo(
Application.routerKey, "/demo/fixedtrans?message=Hello!&color_hex=#f4424b");
} else {
message = "You tapped the function button!";
Application.router.navigateTo(context, "/demo/func?message=$message");
Application.router.navigateTo(Application.routerKey, "/demo/func?message=$message");
}
}
}

View File

@ -1,12 +1,16 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
class Application {
static Router router;
static GlobalKey<NavigatorState> routerKey = GlobalKey<NavigatorState>();
}

View File

@ -1,8 +1,9 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import '../helpers/color_helpers.dart';
@ -12,49 +13,48 @@ import 'package:flutter/painting.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
var rootHandler = new Handler(
var rootHandler = Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
return new HomeComponent();
return HomeComponent();
});
var demoRouteHandler = new Handler(
var demoRouteHandler = Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
String message = params["message"]?.first;
String colorHex = params["color_hex"]?.first;
String result = params["result"]?.first;
Color color = new Color(0xFFFFFFFF);
Color color = Color(0xFFFFFFFF);
if (colorHex != null && colorHex.length > 0) {
color = new Color(ColorHelpers.fromHexString(colorHex));
color = Color(ColorHelpers.fromHexString(colorHex));
}
return new DemoSimpleComponent(
message: message, color: color, result: result);
return DemoSimpleComponent(message: message, color: color, result: result);
});
var demoFunctionHandler = new Handler(
var demoFunctionHandler = Handler(
type: HandlerType.function,
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
String message = params["message"]?.first;
showDialog(
context: context,
builder: (context) {
return new AlertDialog(
title: new Text(
return AlertDialog(
title: Text(
"Hey Hey!",
style: new TextStyle(
style: TextStyle(
color: const Color(0xFF00D6F7),
fontFamily: "Lazer84",
fontSize: 22.0,
),
),
content: new Text("$message"),
content: Text("$message"),
actions: <Widget>[
new Padding(
padding: new EdgeInsets.only(bottom: 8.0, right: 8.0),
child: new FlatButton(
Padding(
padding: EdgeInsets.only(bottom: 8.0, right: 8.0),
child: FlatButton(
onPressed: () {
Navigator.of(context).pop(true);
},
child: new Text("OK"),
child: Text("OK"),
),
),
],
@ -66,15 +66,15 @@ var demoFunctionHandler = new Handler(
/// Handles deep links into the app
/// To test on Android:
///
/// `adb shell am start -W -a android.intent.action.VIEW -d "fluro://deeplink?path=/message&mesage=fluro%20rocks%21%21" com.goposse.fluro`
var deepLinkHandler = new Handler(
/// `adb shell am start -W -a android.intent.action.VIEW -d "fluro://deeplink?path=/message&mesage=fluro%20rocks%21%21" com.theyakka.fluro`
var deepLinkHandler = Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
String colorHex = params["color_hex"]?.first;
String result = params["result"]?.first;
Color color = new Color(0xFFFFFFFF);
Color color = Color(0xFFFFFFFF);
if (colorHex != null && colorHex.length > 0) {
color = new Color(ColorHelpers.fromHexString(colorHex));
color = Color(ColorHelpers.fromHexString(colorHex));
}
return new DemoSimpleComponent(
return DemoSimpleComponent(
message: "DEEEEEP LINK!!!", color: color, result: result);
});

View File

@ -1,8 +1,9 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import 'package:fluro/fluro.dart';
@ -12,16 +13,19 @@ import './route_handlers.dart';
class Routes {
static String root = "/";
static String demoSimple = "/demo";
static String demoSimpleFixedTrans = "/demo/fixedtrans";
static String demoFunc = "/demo/func";
static String deepLink = "/message";
static void configureRoutes(Router router) {
router.notFoundHandler = new Handler(
router.notFoundHandler = Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
print("ROUTE WAS NOT FOUND !!!");
});
router.define(root, handler: rootHandler);
router.define(demoSimple, handler: demoRouteHandler);
router.define(demoSimpleFixedTrans,
handler: demoRouteHandler, transitionType: TransitionType.inFromLeft);
router.define(demoFunc, handler: demoFunctionHandler);
router.define(deepLink, handler: deepLinkHandler);
}

View File

@ -1,8 +1,9 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import 'package:flutter/material.dart';
@ -47,10 +48,10 @@ class ColorHelpers {
if (value >= _kMinContrastModifierRange &&
value <= _kMaxContrastModifierRange) {
return prefer == ContrastPreference.light
? new Color(0xFFFFFFFF)
: new Color(0xFF000000);
? Color(0xFFFFFFFF)
: Color(0xFF000000);
}
}
return value > 0.6 ? new Color(0xFF000000) : new Color(0xFFFFFFFF);
return value > 0.6 ? Color(0xFF000000) : Color(0xFFFFFFFF);
}
}

View File

@ -1,13 +1,14 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import 'components/app/app_component.dart';
import 'package:flutter/material.dart';
void main() {
runApp(new AppComponent());
runApp(AppComponent());
}

View File

@ -11,6 +11,13 @@ flutter:
assets:
- assets/images/logo_fluro.png
- assets/images/acc_boom.png
- assets/images/ic_result_hz.png
- assets/images/ic_function_hz.png
- assets/images/ic_transform_custom_hz.png
- assets/images/ic_transform_fade_in_hz.png
- assets/images/ic_transform_fade_out_hz.png
- assets/images/ic_transform_global_hz.png
- assets/images/ic_transform_native_hz.png
fonts:
- family: Lazer84
fonts:

View File

@ -1,8 +1,9 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
library fluro;

View File

@ -1,8 +1,9 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
@ -16,7 +17,7 @@ enum HandlerType {
///
class Handler {
Handler({this.type = HandlerType.route, this.handlerFunc});
const Handler({this.type = HandlerType.route, this.handlerFunc});
final HandlerType type;
final HandlerFunc handlerFunc;
}
@ -33,7 +34,22 @@ typedef Widget HandlerFunc(
class AppRoute {
String route;
dynamic handler;
AppRoute(this.route, this.handler);
TransitionType transitionType;
AppRoute(this.route, this.handler, {this.transitionType});
}
enum TransitionType {
native,
nativeModal,
inFromLeft,
inFromRight,
inFromBottom,
fadeIn,
custom, // if using custom then you must also provide a transition
material,
materialFullScreenDialog,
cupertino,
cupertinoFullScreenDialog,
}
enum RouteMatchType {
@ -52,3 +68,14 @@ class RouteMatch {
final RouteMatchType matchType;
final String errorMessage;
}
class RouteNotFoundException implements Exception {
final String message;
final String path;
RouteNotFoundException(this.message, this.path);
@override
String toString() {
return "No registered route was found to handle '$path'";
}
}

View File

@ -1,8 +1,9 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
@ -10,31 +11,25 @@ import 'dart:async';
import 'package:fluro/fluro.dart';
import 'package:fluro/src/common.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
enum TransitionType {
native,
nativeModal,
inFromLeft,
inFromRight,
inFromBottom,
fadeIn,
custom, // if using custom then you must also provide a transition
}
class Router {
static final appRouter = new Router();
static final appRouter = Router();
/// The tree structure that stores the defined routes
final RouteTree _routeTree = new RouteTree();
final RouteTree _routeTree = RouteTree();
/// Generic handler for when a route has not been defined
Handler notFoundHandler;
/// Creates a [PageRoute] definition for the passed [RouteHandler]. You can optionally provide a custom
/// transition builder for the route.
void define(String routePath, {@required Handler handler}) {
_routeTree.addRoute(new AppRoute(routePath, handler));
/// Creates a [PageRoute] definition for the passed [RouteHandler]. You can optionally provide a default transition type.
void define(String routePath,
{@required Handler handler, TransitionType transitionType}) {
_routeTree.addRoute(
AppRoute(routePath, handler, transitionType: transitionType),
);
}
/// Finds a defined [AppRoute] for the path value. If no [AppRoute] definition was found
@ -43,34 +38,42 @@ class Router {
return _routeTree.matchRoute(path);
}
void pop(GlobalKey<NavigatorState> key) => key.currentState.pop();
///
Future navigateTo(BuildContext context, String path,
Future navigateTo(GlobalKey<NavigatorState> key, String path,
{bool replace = false,
TransitionType transition = TransitionType.native,
bool clearStack = false,
TransitionType transition,
Duration transitionDuration = const Duration(milliseconds: 250),
RouteTransitionsBuilder transitionBuilder}) {
RouteMatch routeMatch = matchRoute(context, path,
RouteMatch routeMatch = matchRoute(key.currentContext, path,
transitionType: transition,
transitionsBuilder: transitionBuilder,
transitionDuration: transitionDuration);
Route<dynamic> route = routeMatch.route;
Completer completer = new Completer();
Completer completer = Completer();
Future future = completer.future;
if (routeMatch.matchType == RouteMatchType.nonVisual) {
completer.complete("Non visual route type.");
} else {
if (route == null && notFoundHandler != null) {
route = _notFoundRoute(context, path);
route = _notFoundRoute(path);
}
if (route != null) {
future = replace
? Navigator.pushReplacement(context, route)
: Navigator.push(context, route);
if (clearStack) {
future =
key.currentState.pushAndRemoveUntil(route, (check) => false);
} else {
future = replace
? key.currentState.pushReplacement(route)
: key.currentState.push(route);
}
completer.complete();
} else {
String error = "No registered route was found to handle '$path'.";
print(error);
completer.completeError(error);
completer.completeError(RouteNotFoundException(error, path));
}
}
@ -78,16 +81,16 @@ class Router {
}
///
Route<Null> _notFoundRoute(BuildContext context, String path) {
Route<Null> _notFoundRoute(String path) {
RouteCreator<Null> creator =
(RouteSettings routeSettings, Map<String, List<String>> parameters) {
return new MaterialPageRoute<Null>(
return MaterialPageRoute<Null>(
settings: routeSettings,
builder: (BuildContext context) {
return notFoundHandler.handlerFunc(context, parameters);
});
};
return creator(new RouteSettings(name: path), null);
return creator(RouteSettings(name: path), null);
}
///
@ -98,13 +101,17 @@ class Router {
RouteTransitionsBuilder transitionsBuilder}) {
RouteSettings settingsToUse = routeSettings;
if (routeSettings == null) {
settingsToUse = new RouteSettings(name: path);
settingsToUse = RouteSettings(name: path);
}
AppRouteMatch match = _routeTree.matchRoute(path);
AppRoute route = match?.route;
Handler handler = (route != null ? route.handler : notFoundHandler);
var transition = transitionType;
if (transitionType == null) {
transition = route != null ? route.transitionType : TransitionType.native;
}
if (route == null && notFoundHandler == null) {
return new RouteMatch(
return RouteMatch(
matchType: RouteMatchType.noMatch,
errorMessage: "No matching route was found");
}
@ -112,28 +119,55 @@ class Router {
match?.parameters ?? <String, List<String>>{};
if (handler.type == HandlerType.function) {
handler.handlerFunc(buildContext, parameters);
return new RouteMatch(matchType: RouteMatchType.nonVisual);
return RouteMatch(matchType: RouteMatchType.nonVisual);
}
RouteCreator creator =
(RouteSettings routeSettings, Map<String, List<String>> parameters) {
bool isNativeTransition = (transitionType == TransitionType.native ||
transitionType == TransitionType.nativeModal);
bool isNativeTransition = (transition == TransitionType.native ||
transition == TransitionType.nativeModal);
if (isNativeTransition) {
return new MaterialPageRoute<dynamic>(
if (Theme.of(buildContext).platform == TargetPlatform.iOS) {
return CupertinoPageRoute<dynamic>(
settings: routeSettings,
fullscreenDialog: transition == TransitionType.nativeModal,
builder: (BuildContext context) {
return handler.handlerFunc(context, parameters);
});
} else {
return MaterialPageRoute<dynamic>(
settings: routeSettings,
fullscreenDialog: transition == TransitionType.nativeModal,
builder: (BuildContext context) {
return handler.handlerFunc(context, parameters);
});
}
} else if (transition == TransitionType.material ||
transition == TransitionType.materialFullScreenDialog) {
return MaterialPageRoute<dynamic>(
settings: routeSettings,
fullscreenDialog: transitionType == TransitionType.nativeModal,
fullscreenDialog:
transition == TransitionType.materialFullScreenDialog,
builder: (BuildContext context) {
return handler.handlerFunc(context, parameters);
});
} else if (transition == TransitionType.cupertino ||
transition == TransitionType.cupertinoFullScreenDialog) {
return CupertinoPageRoute<dynamic>(
settings: routeSettings,
fullscreenDialog:
transition == TransitionType.cupertinoFullScreenDialog,
builder: (BuildContext context) {
return handler.handlerFunc(context, parameters);
});
} else {
var routeTransitionsBuilder;
if (transitionType == TransitionType.custom) {
if (transition == TransitionType.custom) {
routeTransitionsBuilder = transitionsBuilder;
} else {
routeTransitionsBuilder = _standardTransitionsBuilder(transitionType);
routeTransitionsBuilder = _standardTransitionsBuilder(transition);
}
return new PageRouteBuilder<dynamic>(
return PageRouteBuilder<dynamic>(
settings: routeSettings,
pageBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
@ -144,7 +178,7 @@ class Router {
);
}
};
return new RouteMatch(
return RouteMatch(
matchType: RouteMatchType.visual,
route: creator(settingsToUse, parameters),
);
@ -155,7 +189,7 @@ class Router {
return (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
if (transitionType == TransitionType.fadeIn) {
return new FadeTransition(opacity: animation, child: child);
return FadeTransition(opacity: animation, child: child);
} else {
const Offset topLeft = const Offset(0.0, 0.0);
const Offset topRight = const Offset(1.0, 0.0);
@ -170,8 +204,8 @@ class Router {
endOffset = topLeft;
}
return new SlideTransition(
position: new Tween<Offset>(
return SlideTransition(
position: Tween<Offset>(
begin: startOffset,
end: endOffset,
).animate(animation),

View File

@ -1,8 +1,9 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
@ -70,7 +71,7 @@ class RouteTree {
// could be affected
throw ("Default route was already defined");
}
var node = new RouteTreeNode(path, RouteTreeNodeType.component);
var node = RouteTreeNode(path, RouteTreeNodeType.component);
node.routes = [route];
_nodes.add(node);
_hasDefaultRoute = true;
@ -86,7 +87,7 @@ class RouteTree {
RouteTreeNode node = _nodeForComponent(component, parent);
if (node == null) {
RouteTreeNodeType type = _typeForComponent(component);
node = new RouteTreeNode(component, type);
node = RouteTreeNode(component, type);
node.parent = parent;
if (parent == null) {
_nodes.add(node);
@ -134,7 +135,7 @@ class RouteTree {
if (isMatch) {
RouteTreeNodeMatch parentMatch = nodeMatches[node.parent];
RouteTreeNodeMatch match =
new RouteTreeNodeMatch.fromMatch(parentMatch, node);
RouteTreeNodeMatch.fromMatch(parentMatch, node);
if (node.isParameter()) {
String paramKey = node.part.substring(1);
match.parameters[paramKey] = [pathPart];
@ -164,7 +165,7 @@ class RouteTree {
nodeToUse.routes != null &&
nodeToUse.routes.length > 0) {
List<AppRoute> routes = nodeToUse.routes;
AppRouteMatch routeMatch = new AppRouteMatch(routes[0]);
AppRouteMatch routeMatch = AppRouteMatch(routes[0]);
routeMatch.parameters = match.parameters;
return routeMatch;
}
@ -218,8 +219,8 @@ class RouteTree {
}
Map<String, List<String>> parseQueryString(String query) {
var search = new RegExp('([^&=]+)=?([^&]*)');
var params = new Map<String, List<String>>();
var search = RegExp('([^&=]+)=?([^&]*)');
var params = Map<String, List<String>>();
if (query.startsWith('?')) query = query.substring(1);
decode(String s) => Uri.decodeComponent(s.replaceAll('+', ' '));
for (Match match in search.allMatches(query)) {

View File

@ -2,12 +2,12 @@ name: fluro
description: >
Fluro is a Flutter routing library that adds flexible routing options like wildcards, named
parameters and clear route definitions.
version: 1.3.4
author: Yakka, LLC <flutter@theyakka.com>
version: 1.6.3
homepage: https://github.com/theyakka/fluro
environment:
sdk: ">=2.0.0-dev.58.0 <3.0.0"
sdk: ">=2.6.0 <3.0.0"
flutter: ">=1.12.0"
dependencies:
flutter:
@ -16,7 +16,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
test: ">=0.12.30+3 <0.13.0"
test: ^1.6.0
flutter:
uses-material-design: false

View File

@ -1,8 +1,9 @@
/*
* fluro
* A Posse Production
* http://goposse.com
* Copyright (c) 2018 Posse Productions LLC. All rights reserved.
* Created by Yakka
* https://theyakka.com
*
* Copyright (c) 2019 Yakka, LLC. All rights reserved.
* See LICENSE for distribution and usage details.
*/
@ -14,7 +15,7 @@ void main() {
(WidgetTester tester) async {
String path = "/users/1234";
String route = "/users/:id";
Router router = new Router();
Router router = Router();
router.define(route, handler: null);
AppRouteMatch match = router.match(path);
expect(
@ -28,7 +29,7 @@ void main() {
(WidgetTester tester) async {
String path = "/users/1234?name=luke";
String route = "/users/:id";
Router router = new Router();
Router router = Router();
router.define(route, handler: null);
AppRouteMatch match = router.match(path);
expect(
@ -43,7 +44,7 @@ void main() {
(WidgetTester tester) async {
String path = "/users/create?name=luke&phrase=hello%20world&number=7";
String route = "/users/create";
Router router = new Router();
Router router = Router();
router.define(route, handler: null);
AppRouteMatch match = router.match(path);
expect(
@ -60,7 +61,7 @@ void main() {
String path =
"/users/create?name=luke&phrase=hello%20world&number=7&number=10&number=13";
String route = "/users/create";
Router router = new Router();
Router router = Router();
router.define(route, handler: null);
AppRouteMatch match = router.match(path);
expect(
@ -71,4 +72,14 @@ void main() {
"number": ["7", "10", "13"],
}));
});
testWidgets("Router correctly matches route and transition type",
(WidgetTester tester) async {
String path = "/users/1234";
String route = "/users/:id";
Router router = Router();
router.define(route,
handler: null, transitionType: TransitionType.inFromRight);
AppRouteMatch match = router.match(path);
expect(TransitionType.inFromRight, match.route.transitionType);
});
}