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);
}
final _router = GoRouter(
initialLocation: '/splashScreen',
routes: [
...getStartRoutes(),
],
);
List<GoRoute> getStartRoutes() => getStartStoryRoutes(
config,
);
StartUserStoryConfiguration config = StartUserStoryConfiguration(
introductionService: IntroductionService(
ExampleIntroductionDataProvider(),
),
useKillswitch: true,
// showIntroduction: false,
splashScreenBuilder: (context, onFinish) => SplashScreen(
onFinish: onFinish,

View file

@ -22,7 +22,7 @@ List<GoRoute> getStartStoryRoutes(
path: StartUserStoryRoutes.splashScreen,
pageBuilder: (context, state) {
var go = context.go;
var killSwitchIsActive = false;
var isAllowedToPassThrough = false;
var introductionSeen = false;
Future<void> myFunction() async {
await Future.wait<void>(
@ -33,7 +33,7 @@ List<GoRoute> getStartStoryRoutes(
Duration.zero,
() async {
if (configuration.useKillswitch)
killSwitchIsActive =
isAllowedToPassThrough =
await KillswitchService().isKillswitchActive();
var introService = configuration.introductionService ??
IntroductionService(
@ -51,7 +51,7 @@ List<GoRoute> getStartStoryRoutes(
],
);
if (configuration.useKillswitch && killSwitchIsActive) return;
if (configuration.useKillswitch && !isAllowedToPassThrough) return;
if (!configuration.showIntroduction ||
(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,
) {
var navigator = Navigator.of(context);
var killSwitchIsActive = false;
var isAllowedToPassThrough = false;
var introductionSeen = false;
Future<void> myFunction() async {
await Future.wait<void>(
@ -29,7 +29,7 @@ Widget _splashScreen(
Duration.zero,
() async {
if (configuration.useKillswitch)
killSwitchIsActive =
isAllowedToPassThrough =
await KillswitchService().isKillswitchActive();
var introService = configuration.introductionService ??
IntroductionService(
@ -47,7 +47,7 @@ Widget _splashScreen(
],
);
if (configuration.useKillswitch && killSwitchIsActive) return;
if (configuration.useKillswitch && !isAllowedToPassThrough) return;
if (!configuration.showIntroduction ||
(introductionSeen && !configuration.alwaysShowIntroduction)) {