mirror of
https://github.com/Iconica-Development/flutter_start.git
synced 2025-05-18 18:13:45 +02:00
Merge pull request #6 from Iconica-Development/feature/add_configuration_options
feat: added configuration options
This commit is contained in:
commit
ebe86cf934
8 changed files with 34 additions and 16 deletions
|
@ -1,3 +1,8 @@
|
|||
## 2.0.2
|
||||
|
||||
- Added configuration options
|
||||
- Fixed bug with killswitch
|
||||
|
||||
## 2.0.1
|
||||
|
||||
- Added Iconica Ci
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@ class KillswitchService {
|
|||
Future<bool> 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'),
|
||||
)
|
||||
|
|
|
@ -23,6 +23,7 @@ List<GoRoute> getStartStoryRoutes(
|
|||
pageBuilder: (context, state) {
|
||||
var go = context.go;
|
||||
var killSwitchIsActive = false;
|
||||
var introductionSeen = false;
|
||||
Future<void> myFunction() async {
|
||||
await Future.wait<void>(
|
||||
[
|
||||
|
@ -34,6 +35,11 @@ List<GoRoute> 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<GoRoute> 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,
|
||||
);
|
||||
|
|
|
@ -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<void> myFunction() async {
|
||||
await Future.wait<void>(
|
||||
[
|
||||
|
@ -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),
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue