fix: killswitch

This commit is contained in:
mike doornenbal 2024-02-07 14:27:45 +01:00
parent ebe86cf934
commit 66ef9af8bb
3 changed files with 30 additions and 6 deletions

View file

@ -24,11 +24,22 @@ class Home extends StatelessWidget {
startNavigatorUserStory(config, context); startNavigatorUserStory(config, context);
} }
final _router = GoRouter(
initialLocation: '/splashScreen',
routes: [
...getStartRoutes(),
],
);
List<GoRoute> getStartRoutes() => getStartStoryRoutes( List<GoRoute> getStartRoutes() => getStartStoryRoutes(
config, config,
); );
StartUserStoryConfiguration config = StartUserStoryConfiguration( StartUserStoryConfiguration config = StartUserStoryConfiguration(
introductionService: IntroductionService(
ExampleIntroductionDataProvider(),
),
useKillswitch: true,
// showIntroduction: false, // showIntroduction: false,
splashScreenBuilder: (context, onFinish) => SplashScreen( splashScreenBuilder: (context, onFinish) => SplashScreen(
onFinish: onFinish, onFinish: onFinish,

View file

@ -22,7 +22,7 @@ List<GoRoute> getStartStoryRoutes(
path: StartUserStoryRoutes.splashScreen, path: StartUserStoryRoutes.splashScreen,
pageBuilder: (context, state) { pageBuilder: (context, state) {
var go = context.go; var go = context.go;
var killSwitchIsActive = false; var isAllowedToPassThrough = false;
var introductionSeen = false; var introductionSeen = false;
Future<void> myFunction() async { Future<void> myFunction() async {
await Future.wait<void>( await Future.wait<void>(
@ -33,7 +33,7 @@ List<GoRoute> getStartStoryRoutes(
Duration.zero, Duration.zero,
() async { () async {
if (configuration.useKillswitch) if (configuration.useKillswitch)
killSwitchIsActive = isAllowedToPassThrough =
await KillswitchService().isKillswitchActive(); await KillswitchService().isKillswitchActive();
var introService = configuration.introductionService ?? var introService = configuration.introductionService ??
IntroductionService( IntroductionService(
@ -51,7 +51,7 @@ List<GoRoute> getStartStoryRoutes(
], ],
); );
if (configuration.useKillswitch && killSwitchIsActive) return; if (configuration.useKillswitch && !isAllowedToPassThrough) return;
if (!configuration.showIntroduction || if (!configuration.showIntroduction ||
(introductionSeen && !configuration.alwaysShowIntroduction)) { (introductionSeen && !configuration.alwaysShowIntroduction)) {
@ -114,4 +114,17 @@ List<GoRoute> getStartStoryRoutes(
); );
}, },
), ),
GoRoute(
path: StartUserStoryRoutes.home,
pageBuilder: (context, state) {
var home = configuration.homeEntry;
return buildScreenWithoutTransition(
context: context,
state: state,
child: Scaffold(
body: home,
),
);
},
),
]; ];

View file

@ -19,7 +19,7 @@ Widget _splashScreen(
BuildContext context, BuildContext context,
) { ) {
var navigator = Navigator.of(context); var navigator = Navigator.of(context);
var killSwitchIsActive = false; var isAllowedToPassThrough = false;
var introductionSeen = false; var introductionSeen = false;
Future<void> myFunction() async { Future<void> myFunction() async {
await Future.wait<void>( await Future.wait<void>(
@ -29,7 +29,7 @@ Widget _splashScreen(
Duration.zero, Duration.zero,
() async { () async {
if (configuration.useKillswitch) if (configuration.useKillswitch)
killSwitchIsActive = isAllowedToPassThrough =
await KillswitchService().isKillswitchActive(); await KillswitchService().isKillswitchActive();
var introService = configuration.introductionService ?? var introService = configuration.introductionService ??
IntroductionService( IntroductionService(
@ -47,7 +47,7 @@ Widget _splashScreen(
], ],
); );
if (configuration.useKillswitch && killSwitchIsActive) return; if (configuration.useKillswitch && !isAllowedToPassThrough) return;
if (!configuration.showIntroduction || if (!configuration.showIntroduction ||
(introductionSeen && !configuration.alwaysShowIntroduction)) { (introductionSeen && !configuration.alwaysShowIntroduction)) {