diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 6a95527..dd03af4 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"image_picker_saver","path":"C:\\\\Users\\\\hll\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.flutter-io.cn\\\\image_picker_saver-0.3.0\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\hll\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.flutter-io.cn\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\Users\\\\hll\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.flutter-io.cn\\\\url_launcher-5.3.0\\\\","dependencies":[]}],"android":[{"name":"image_picker_saver","path":"C:\\\\Users\\\\hll\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.flutter-io.cn\\\\image_picker_saver-0.3.0\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\hll\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.flutter-io.cn\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\Users\\\\hll\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.flutter-io.cn\\\\url_launcher-5.3.0\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"url_launcher_web","path":"C:\\\\Users\\\\hll\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.flutter-io.cn\\\\url_launcher_web-0.1.0+2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"image_picker_saver","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web"]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-02-05 19:25:44.490791","version":"1.14.6"} \ No newline at end of file +{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"image_picker_saver","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web"]},{"name":"url_launcher_web","dependencies":[]}]} \ No newline at end of file diff --git a/example/ff_annotation_route_commands b/example/ff_annotation_route_commands new file mode 100644 index 0000000..6529596 --- /dev/null +++ b/example/ff_annotation_route_commands @@ -0,0 +1 @@ +-rh, -rn \ No newline at end of file diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index c3fba5b..06cbc0b 100644 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -1,10 +1,10 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=D:\zmt\flutter\dev" -export "FLUTTER_APPLICATION_PATH=D:\zmt\FlutterCandies\dev\extended_text_field\example" +export "FLUTTER_ROOT=E:\Flutter\flutter_source\1.12.13" +export "FLUTTER_APPLICATION_PATH=E:\Flutter\FlutterCandies\dev\extended_text_field\example" export "FLUTTER_TARGET=lib\main.dart" export "FLUTTER_BUILD_DIR=build" export "SYMROOT=${SOURCE_ROOT}/../build\ios" -export "FLUTTER_FRAMEWORK_DIR=D:\zmt\flutter\dev\bin\cache\artifacts\engine\ios" +export "FLUTTER_FRAMEWORK_DIR=E:\Flutter\flutter_source\1.12.13\bin\cache\artifacts\engine\ios" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" diff --git a/example/lib/example_route.dart b/example/lib/example_route.dart index 193c218..fccc6f0 100644 --- a/example/lib/example_route.dart +++ b/example/lib/example_route.dart @@ -1,9 +1,10 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND +// GENERATED CODE - DO NOT MODIFY MANUALLY // ************************************************************************** -// auto generated by https://github.com/fluttercandies/ff_annotation_route +// Auto generated by https://github.com/fluttercandies/ff_annotation_route // ************************************************************************** import 'package:flutter/widgets.dart'; + import 'pages/custom_toolbar.dart'; import 'pages/main_page.dart'; import 'pages/pic_swiper_page.dart'; @@ -12,27 +13,12 @@ import 'pages/widget_span.dart'; RouteResult getRouteResult({String name, Map arguments}) { switch (name) { - case "fluttercandies://picswiper": - return RouteResult( - widget: PicSwiperPage( - index: arguments['index'], - pics: arguments['pics'], - ), - showStatusBar: false, - routeName: "PicSwiper", - pageRouteType: PageRouteType.transparent, - ); case "fluttercandies://CustomToolBar": return RouteResult( widget: CustomToolBar(), routeName: "custom toolbar", description: "custom selection toolbar and handles for text field", ); - case "fluttercandies://mainpage": - return RouteResult( - widget: MainPage(), - routeName: "MainPage", - ); case "fluttercandies://TextDemo": return RouteResult( widget: TextDemo(), @@ -45,6 +31,22 @@ RouteResult getRouteResult({String name, Map arguments}) { routeName: "widget span", description: "mailbox demo with widgetSpan", ); + case "fluttercandies://mainpage": + return RouteResult( + widget: MainPage(), + routeName: "MainPage", + ); + case "fluttercandies://picswiper": + return RouteResult( + widget: PicSwiperPage( + index: arguments['index'], + pics: arguments['pics'], + tuChongItem: arguments['tuChongItem'], + ), + showStatusBar: false, + routeName: "PicSwiper", + pageRouteType: PageRouteType.transparent, + ); default: return RouteResult(); } @@ -66,20 +68,21 @@ class RouteResult { /// The description of route final String description; - const RouteResult( - {this.widget, - this.showStatusBar = true, - this.routeName = '', - this.pageRouteType, - this.description = ''}); + const RouteResult({ + this.widget, + this.showStatusBar = true, + this.routeName = '', + this.pageRouteType, + this.description = '', + }); } enum PageRouteType { material, cupertino, transparent } List routeNames = [ - "fluttercandies://picswiper", "fluttercandies://CustomToolBar", - "fluttercandies://mainpage", "fluttercandies://TextDemo", - "fluttercandies://WidgetSpanDemo" + "fluttercandies://WidgetSpanDemo", + "fluttercandies://mainpage", + "fluttercandies://picswiper" ]; diff --git a/example/lib/example_route_helper.dart b/example/lib/example_route_helper.dart index adb20f8..e62f583 100644 --- a/example/lib/example_route_helper.dart +++ b/example/lib/example_route_helper.dart @@ -1,87 +1,55 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND +// GENERATED CODE - DO NOT MODIFY MANUALLY // ************************************************************************** -// auto generated by https://github.com/fluttercandies/ff_annotation_route -// ************************************************************************** +// Auto generated by https://github.com/fluttercandies/ff_annotation_route +// ************************************************************************** + +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/widgets.dart'; +import 'example_route.dart'; + class FFNavigatorObserver extends NavigatorObserver { - final ShowStatusBarChange showStatusBarChange; final RouteChange routeChange; - FFNavigatorObserver({this.showStatusBarChange, this.routeChange}); + FFNavigatorObserver({this.routeChange}); @override void didPop(Route route, Route previousRoute) { - super.didPop(route, previousRoute); - _showStatusBarChange(previousRoute, route); - _routeChange(previousRoute); + super.didPop(route, previousRoute); + _didRouteChange(previousRoute, route); } @override void didPush(Route route, Route previousRoute) { super.didPush(route, previousRoute); - _showStatusBarChange(route, previousRoute); - _routeChange(route); + _didRouteChange(route, previousRoute); } @override void didRemove(Route route, Route previousRoute) { - super.didRemove(route, previousRoute); - _showStatusBarChange(previousRoute, route); - _routeChange(previousRoute); + super.didRemove(route, previousRoute); + _didRouteChange(previousRoute, route); } @override void didReplace({Route newRoute, Route oldRoute}) { - super.didReplace(newRoute: newRoute, oldRoute: oldRoute); - _showStatusBarChange(newRoute, oldRoute); - _routeChange(newRoute); - } - - @override - void didStartUserGesture(Route route, Route previousRoute) { - super.didStartUserGesture(route, previousRoute); - } - - @override - void didStopUserGesture() { - super.didStopUserGesture(); - } - - void _showStatusBarChange(Route newRoute, Route oldRoute) { - if (showStatusBarChange != null) { - var newSettting = getFFRouteSettings(newRoute); - var oldSetting = getFFRouteSettings(oldRoute); - if (newSettting?.showStatusBar != null && - newSettting.showStatusBar != oldSetting?.showStatusBar) { - showStatusBarChange(newSettting.showStatusBar); - } - } + super.didReplace(newRoute: newRoute, oldRoute: oldRoute); + _didRouteChange(newRoute, oldRoute); } - void _routeChange(Route newRoute) { - if (routeChange != null) { - var newSettting = getFFRouteSettings(newRoute); - if (newSettting?.routeName != null) { - routeChange(newSettting.routeName); - } - } - } - - FFRouteSettings getFFRouteSettings(Route route) { - if (route != null && - route.settings != null && - route.settings is FFRouteSettings) { - return route.settings; - } - return null; + void _didRouteChange(Route newRoute, Route oldRoute) { + // oldRoute may be null when route first time enter. + routeChange?.call(newRoute, oldRoute); } } -typedef ShowStatusBarChange = void Function(bool showStatusBar); - -typedef RouteChange = void Function(String routeName); +typedef RouteChange = void Function( + Route newRoute, + Route oldRoute, +); class FFTransparentPageRoute extends PageRouteBuilder { FFTransparentPageRoute({ @@ -98,25 +66,78 @@ class FFTransparentPageRoute extends PageRouteBuilder { assert(barrierDismissible != null), assert(maintainState != null), super( - settings: settings, - opaque: false, - pageBuilder: pageBuilder, - transitionsBuilder: transitionsBuilder, - transitionDuration: transitionDuration, - barrierDismissible: barrierDismissible, - barrierColor: barrierColor, - barrierLabel: barrierLabel, - maintainState: maintainState); + settings: settings, + opaque: false, + pageBuilder: pageBuilder, + transitionsBuilder: transitionsBuilder, + transitionDuration: transitionDuration, + barrierDismissible: barrierDismissible, + barrierColor: barrierColor, + barrierLabel: barrierLabel, + maintainState: maintainState, + ); } Widget _defaultTransitionsBuilder( - BuildContext context, - Animation animation, - Animation secondaryAnimation, - Widget child) { + BuildContext context, + Animation animation, + Animation secondaryAnimation, + Widget child, +) { return child; } +Route onGenerateRouteHelper( + RouteSettings settings, { + Widget notFoundFallback, + Object arguments, +}) { + arguments ??= settings.arguments; + + final routeResult = getRouteResult( + name: settings.name, + arguments: arguments, + ); + if (routeResult.showStatusBar != null || routeResult.routeName != null) { + settings = FFRouteSettings( + name: settings.name, + isInitialRoute: settings.isInitialRoute, + routeName: routeResult.routeName, + arguments: arguments, + showStatusBar: routeResult.showStatusBar, + ); + } + final page = routeResult.widget ?? notFoundFallback; + if (page == null) { + throw Exception( + '''Route "${settings.name}" returned null.Route Widget must never return null, + maybe the reason is that route name did not match with right path. + You can use parameter[notFoundFallback] to avoid this ugly error.'''); + } + + if (arguments is Map) { + RouteBuilder builder = arguments['routeBuilder']; + if (builder != null) return builder(page); + } + + switch (routeResult.pageRouteType) { + case PageRouteType.material: + return MaterialPageRoute(settings: settings, builder: (_) => page); + case PageRouteType.cupertino: + return CupertinoPageRoute(settings: settings, builder: (_) => page); + case PageRouteType.transparent: + return FFTransparentPageRoute( + settings: settings, + pageBuilder: (_, __, ___) => page, + ); + default: + return Platform.isIOS + ? CupertinoPageRoute(settings: settings, builder: (_) => page) + : MaterialPageRoute(settings: settings, builder: (_) => page); + } +} + +typedef RouteBuilder = PageRoute Function(Widget page); class FFRouteSettings extends RouteSettings { final String routeName; diff --git a/example/lib/main.dart b/example/lib/main.dart index 769fa9a..6ac1713 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -3,7 +3,6 @@ import 'package:extended_image/extended_image.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_candies_demo_library/flutter_candies_demo_library.dart'; import 'package:oktoast/oktoast.dart'; @@ -28,19 +27,6 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: Colors.blue, ), - navigatorObservers: [ - FFNavigatorObserver(routeChange: (name) { - //you can track page here - // print(name); - }, showStatusBarChange: (bool showStatusBar) { - if (showStatusBar) { - SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); - SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark); - } else { - SystemChrome.setEnabledSystemUIOverlays([]); - } - }) - ], builder: (c, w) { ScreenUtil.init(width: 750, height: 1334, allowFontScaling: true); // ScreenUtil.instance = diff --git a/example/lib/pages/pic_swiper_page.dart b/example/lib/pages/pic_swiper_page.dart index 0700727..869a034 100644 --- a/example/lib/pages/pic_swiper_page.dart +++ b/example/lib/pages/pic_swiper_page.dart @@ -5,18 +5,28 @@ import 'package:flutter_candies_demo_library/flutter_candies_demo_library.dart'; @FFRoute( name: "fluttercandies://picswiper", routeName: "PicSwiper", - argumentNames: ["index", "pics"], + argumentNames: [ + "index", + "pics", + "tuChongItem", + ], showStatusBar: false, pageRouteType: PageRouteType.transparent) class PicSwiperPage extends StatelessWidget { final int index; final List pics; - PicSwiperPage({this.index, this.pics}); + final TuChongItem tuChongItem; + PicSwiperPage({ + this.index, + this.pics, + this.tuChongItem, + }); @override Widget build(BuildContext context) { return PicSwiper( index: index, pics: pics, + tuChongItem: tuChongItem, ); } } diff --git a/example/lib/pages/text_demo.dart b/example/lib/pages/text_demo.dart index 1dea8bb..f42e052 100644 --- a/example/lib/pages/text_demo.dart +++ b/example/lib/pages/text_demo.dart @@ -108,14 +108,16 @@ class _TextDemoState extends State { } //image else { + final item = images + .firstWhere((x) => x.imageUrl == value.toString()); Navigator.pushNamed(context, "fluttercandies://picswiper", arguments: { - "index": images.indexOf(images.firstWhere( - (x) => x.imageUrl == value.toString())), - "pics": images + "index": images.indexOf(item), + "pics": item.images .map((f) => PicSwiperItem( picUrl: f.imageUrl, des: f.title)) .toList(), + 'tuChongItem': item, }); } }, diff --git a/example/pubspec.lock b/example/pubspec.lock index c5251e5..1452f12 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -91,14 +91,14 @@ packages: name: extended_image url: "https://pub.flutter-io.cn" source: hosted - version: "0.7.1" + version: "0.7.2" extended_image_library: dependency: transitive description: name: extended_image_library url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.0" + version: "0.2.1" extended_list: dependency: "direct main" description: @@ -126,7 +126,7 @@ packages: path: ".." relative: true source: path - version: "0.4.9" + version: "0.5.0" extended_text_library: dependency: transitive description: @@ -140,7 +140,7 @@ packages: name: ff_annotation_route url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.6" + version: "2.0.3" flutter: dependency: "direct main" description: flutter @@ -151,7 +151,7 @@ packages: description: path: "." ref: HEAD - resolved-ref: "14c71d92ae78b9247fbfe3b54b0d949af0ba0576" + resolved-ref: "28110f44c250a2f4cc937a89fbc57bc3937e6d53" url: "https://github.com/fluttercandies/flutter_candies_demo_library.git" source: git version: "0.1.0" @@ -199,7 +199,7 @@ packages: name: http_parser url: "https://pub.flutter-io.cn" source: hosted - version: "3.1.3" + version: "3.1.4" image: dependency: transitive description: @@ -221,6 +221,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.15.8" + io: + dependency: transitive + description: + name: io + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.3.3" js: dependency: transitive description: @@ -241,7 +248,7 @@ packages: name: loading_more_list url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.4" + version: "1.0.5" loading_more_list_library: dependency: transitive description: @@ -283,14 +290,14 @@ packages: name: oktoast url: "https://pub.flutter-io.cn" source: hosted - version: "2.3.0" + version: "2.3.1+1" package_config: dependency: transitive description: name: package_config url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0" + version: "1.9.2" path: dependency: transitive description: @@ -304,7 +311,21 @@ packages: name: path_provider url: "https://pub.flutter-io.cn" source: hosted - version: "1.6.0" + version: "1.6.5" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.0.4" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.1" pedantic: dependency: transitive description: @@ -332,21 +353,21 @@ packages: name: plugin_platform_interface url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.1" + version: "1.0.2" pub_semver: dependency: transitive description: name: pub_semver url: "https://pub.flutter-io.cn" source: hosted - version: "1.4.2" + version: "1.4.4" pull_to_refresh_notification: dependency: transitive description: name: pull_to_refresh_notification url: "https://pub.flutter-io.cn" source: hosted - version: "0.3.3" + version: "0.3.4" quiver: dependency: transitive description: @@ -421,14 +442,14 @@ packages: name: url_launcher_platform_interface url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.5" + version: "1.0.6" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.0+2" + version: "0.1.1+1" vector_math: dependency: transitive description: @@ -442,14 +463,14 @@ packages: name: watcher url: "https://pub.flutter-io.cn" source: hosted - version: "0.9.7+13" + version: "0.9.7+14" waterfall_flow: dependency: transitive description: name: waterfall_flow url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.2" + version: "0.1.3" xml: dependency: transitive description: @@ -465,5 +486,5 @@ packages: source: hosted version: "2.2.0" sdks: - dart: ">=2.6.0 <3.0.0" + dart: ">=2.7.0 <3.0.0" flutter: ">=1.12.13 <2.0.0"