diff --git a/CHANGELOG.md b/CHANGELOG.md index 412effc..203d78d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.0.2 + +- Added configuration options +- Fixed bug with killswitch + ## 2.0.1 - Added Iconica Ci diff --git a/example/lib/main.dart b/example/lib/main.dart index 725adb9..4d503ed 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter_introduction_shared_preferences/flutter_introduction_shared_preferences.dart'; import 'package:flutter_start/flutter_start.dart'; import 'package:go_router/go_router.dart'; diff --git a/lib/flutter_start.dart b/lib/flutter_start.dart index b6623f3..1ff6b63 100644 --- a/lib/flutter_start.dart +++ b/lib/flutter_start.dart @@ -1,4 +1,5 @@ export 'package:flutter_introduction/flutter_introduction.dart'; +export 'package:flutter_introduction_shared_preferences/flutter_introduction_shared_preferences.dart'; export 'package:flutter_start/src/models/start_configuration.dart'; export 'package:flutter_start/src/routes.dart'; export 'package:flutter_start/src/user_stories/flutter_start_userstory_go_router.dart'; diff --git a/lib/src/models/start_configuration.dart b/lib/src/models/start_configuration.dart index 29437f8..9c1bcc2 100644 --- a/lib/src/models/start_configuration.dart +++ b/lib/src/models/start_configuration.dart @@ -13,6 +13,7 @@ class StartUserStoryConfiguration { this.introductionFallbackScreen, this.introductionScrollPhysics, this.showIntroduction = true, + this.alwaysShowIntroduction = false, this.useKillswitch = false, this.minimumSplashScreenDuration = 3, this.splashScreenFuture, @@ -46,6 +47,9 @@ class StartUserStoryConfiguration { /// If the introduction should be shown. final bool showIntroduction; + /// If this is true the introduction will always be shown. + final bool alwaysShowIntroduction; + /// If the killswitch is enabled this app can be remotely disabled. final bool useKillswitch; diff --git a/lib/src/services/killswitch_service.dart b/lib/src/services/killswitch_service.dart index 55c983c..14e02d9 100644 --- a/lib/src/services/killswitch_service.dart +++ b/lib/src/services/killswitch_service.dart @@ -7,7 +7,9 @@ class KillswitchService { Future isKillswitchActive() async { var packageInfo = await PackageInfo.fromPlatform(); var appName = packageInfo.appName; - var response = await http + http.Response response; + + response = await http .get( Uri.parse('https://active-obelugnnza-uc.a.run.app/?appName=$appName'), ) diff --git a/lib/src/user_stories/flutter_start_userstory_go_router.dart b/lib/src/user_stories/flutter_start_userstory_go_router.dart index 04dcbd6..e4d8f78 100644 --- a/lib/src/user_stories/flutter_start_userstory_go_router.dart +++ b/lib/src/user_stories/flutter_start_userstory_go_router.dart @@ -23,6 +23,7 @@ List getStartStoryRoutes( pageBuilder: (context, state) { var go = context.go; var killSwitchIsActive = false; + var introductionSeen = false; Future myFunction() async { await Future.wait( [ @@ -34,6 +35,11 @@ List getStartStoryRoutes( if (configuration.useKillswitch) killSwitchIsActive = await KillswitchService().isKillswitchActive(); + var introService = configuration.introductionService ?? + IntroductionService( + SharedPreferencesIntroductionDataProvider(), + ); + introductionSeen = !await introService.shouldShow(); }, ), Future.delayed( @@ -45,12 +51,10 @@ List getStartStoryRoutes( ], ); - if (configuration.useKillswitch) { - if (!killSwitchIsActive) { - return; - } - } - if (!configuration.showIntroduction) { + if (configuration.useKillswitch && killSwitchIsActive) return; + + if (!configuration.showIntroduction || + (introductionSeen && !configuration.alwaysShowIntroduction)) { return go( configuration.homeScreenRoute ?? StartUserStoryRoutes.home, ); diff --git a/lib/src/user_stories/flutter_start_userstory_navigator.dart b/lib/src/user_stories/flutter_start_userstory_navigator.dart index 39ac17d..2945839 100644 --- a/lib/src/user_stories/flutter_start_userstory_navigator.dart +++ b/lib/src/user_stories/flutter_start_userstory_navigator.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter_introduction_shared_preferences/flutter_introduction_shared_preferences.dart'; import 'package:flutter_start/flutter_start.dart'; import 'package:flutter_start/src/services/killswitch_service.dart'; @@ -21,6 +20,7 @@ Widget _splashScreen( ) { var navigator = Navigator.of(context); var killSwitchIsActive = false; + var introductionSeen = false; Future myFunction() async { await Future.wait( [ @@ -31,6 +31,11 @@ Widget _splashScreen( if (configuration.useKillswitch) killSwitchIsActive = await KillswitchService().isKillswitchActive(); + var introService = configuration.introductionService ?? + IntroductionService( + SharedPreferencesIntroductionDataProvider(), + ); + introductionSeen = !await introService.shouldShow(); }, ), Future.delayed( @@ -42,12 +47,10 @@ Widget _splashScreen( ], ); - if (configuration.useKillswitch) { - if (!killSwitchIsActive) { - return; - } - } - if (!configuration.showIntroduction) { + if (configuration.useKillswitch && killSwitchIsActive) return; + + if (!configuration.showIntroduction || + (introductionSeen && !configuration.alwaysShowIntroduction)) { await navigator.pushReplacement( MaterialPageRoute( builder: (context) => _home(configuration, context), diff --git a/pubspec.yaml b/pubspec.yaml index e29e2c2..9c7f3e1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_start description: "Flutter_start is a package that allows you to jumpstart your application with a splashScreen, introduction and a home." publish_to: "none" -version: 2.0.1 +version: 2.0.2 environment: sdk: ">=3.2.5 <4.0.0"