mirror of
https://github.com/Iconica-Development/flutter_start.git
synced 2025-05-18 18:13:45 +02:00
feat: added configuration options
This commit is contained in:
parent
76f7ec6105
commit
4f5a301f19
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
|
## 2.0.1
|
||||||
|
|
||||||
- Added Iconica Ci
|
- Added Iconica Ci
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import 'package:flutter/material.dart';
|
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/flutter_start.dart';
|
||||||
|
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
export 'package:flutter_introduction/flutter_introduction.dart';
|
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/models/start_configuration.dart';
|
||||||
export 'package:flutter_start/src/routes.dart';
|
export 'package:flutter_start/src/routes.dart';
|
||||||
export 'package:flutter_start/src/user_stories/flutter_start_userstory_go_router.dart';
|
export 'package:flutter_start/src/user_stories/flutter_start_userstory_go_router.dart';
|
||||||
|
|
|
@ -13,6 +13,7 @@ class StartUserStoryConfiguration {
|
||||||
this.introductionFallbackScreen,
|
this.introductionFallbackScreen,
|
||||||
this.introductionScrollPhysics,
|
this.introductionScrollPhysics,
|
||||||
this.showIntroduction = true,
|
this.showIntroduction = true,
|
||||||
|
this.alwaysShowIntroduction = false,
|
||||||
this.useKillswitch = false,
|
this.useKillswitch = false,
|
||||||
this.minimumSplashScreenDuration = 3,
|
this.minimumSplashScreenDuration = 3,
|
||||||
this.splashScreenFuture,
|
this.splashScreenFuture,
|
||||||
|
@ -46,6 +47,9 @@ class StartUserStoryConfiguration {
|
||||||
/// If the introduction should be shown.
|
/// If the introduction should be shown.
|
||||||
final bool showIntroduction;
|
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.
|
/// If the killswitch is enabled this app can be remotely disabled.
|
||||||
final bool useKillswitch;
|
final bool useKillswitch;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@ class KillswitchService {
|
||||||
Future<bool> isKillswitchActive() async {
|
Future<bool> isKillswitchActive() async {
|
||||||
var packageInfo = await PackageInfo.fromPlatform();
|
var packageInfo = await PackageInfo.fromPlatform();
|
||||||
var appName = packageInfo.appName;
|
var appName = packageInfo.appName;
|
||||||
var response = await http
|
http.Response response;
|
||||||
|
|
||||||
|
response = await http
|
||||||
.get(
|
.get(
|
||||||
Uri.parse('https://active-obelugnnza-uc.a.run.app/?appName=$appName'),
|
Uri.parse('https://active-obelugnnza-uc.a.run.app/?appName=$appName'),
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,6 +23,7 @@ List<GoRoute> getStartStoryRoutes(
|
||||||
pageBuilder: (context, state) {
|
pageBuilder: (context, state) {
|
||||||
var go = context.go;
|
var go = context.go;
|
||||||
var killSwitchIsActive = false;
|
var killSwitchIsActive = false;
|
||||||
|
var introductionSeen = false;
|
||||||
Future<void> myFunction() async {
|
Future<void> myFunction() async {
|
||||||
await Future.wait<void>(
|
await Future.wait<void>(
|
||||||
[
|
[
|
||||||
|
@ -34,6 +35,11 @@ List<GoRoute> getStartStoryRoutes(
|
||||||
if (configuration.useKillswitch)
|
if (configuration.useKillswitch)
|
||||||
killSwitchIsActive =
|
killSwitchIsActive =
|
||||||
await KillswitchService().isKillswitchActive();
|
await KillswitchService().isKillswitchActive();
|
||||||
|
var introService = configuration.introductionService ??
|
||||||
|
IntroductionService(
|
||||||
|
SharedPreferencesIntroductionDataProvider(),
|
||||||
|
);
|
||||||
|
introductionSeen = !await introService.shouldShow();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Future.delayed(
|
Future.delayed(
|
||||||
|
@ -45,12 +51,10 @@ List<GoRoute> getStartStoryRoutes(
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (configuration.useKillswitch) {
|
if (configuration.useKillswitch && killSwitchIsActive) return;
|
||||||
if (!killSwitchIsActive) {
|
|
||||||
return;
|
if (!configuration.showIntroduction ||
|
||||||
}
|
(introductionSeen && !configuration.alwaysShowIntroduction)) {
|
||||||
}
|
|
||||||
if (!configuration.showIntroduction) {
|
|
||||||
return go(
|
return go(
|
||||||
configuration.homeScreenRoute ?? StartUserStoryRoutes.home,
|
configuration.homeScreenRoute ?? StartUserStoryRoutes.home,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import 'package:flutter/material.dart';
|
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/flutter_start.dart';
|
||||||
import 'package:flutter_start/src/services/killswitch_service.dart';
|
import 'package:flutter_start/src/services/killswitch_service.dart';
|
||||||
|
|
||||||
|
@ -21,6 +20,7 @@ Widget _splashScreen(
|
||||||
) {
|
) {
|
||||||
var navigator = Navigator.of(context);
|
var navigator = Navigator.of(context);
|
||||||
var killSwitchIsActive = false;
|
var killSwitchIsActive = false;
|
||||||
|
var introductionSeen = false;
|
||||||
Future<void> myFunction() async {
|
Future<void> myFunction() async {
|
||||||
await Future.wait<void>(
|
await Future.wait<void>(
|
||||||
[
|
[
|
||||||
|
@ -31,6 +31,11 @@ Widget _splashScreen(
|
||||||
if (configuration.useKillswitch)
|
if (configuration.useKillswitch)
|
||||||
killSwitchIsActive =
|
killSwitchIsActive =
|
||||||
await KillswitchService().isKillswitchActive();
|
await KillswitchService().isKillswitchActive();
|
||||||
|
var introService = configuration.introductionService ??
|
||||||
|
IntroductionService(
|
||||||
|
SharedPreferencesIntroductionDataProvider(),
|
||||||
|
);
|
||||||
|
introductionSeen = !await introService.shouldShow();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Future.delayed(
|
Future.delayed(
|
||||||
|
@ -42,12 +47,10 @@ Widget _splashScreen(
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (configuration.useKillswitch) {
|
if (configuration.useKillswitch && killSwitchIsActive) return;
|
||||||
if (!killSwitchIsActive) {
|
|
||||||
return;
|
if (!configuration.showIntroduction ||
|
||||||
}
|
(introductionSeen && !configuration.alwaysShowIntroduction)) {
|
||||||
}
|
|
||||||
if (!configuration.showIntroduction) {
|
|
||||||
await navigator.pushReplacement(
|
await navigator.pushReplacement(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => _home(configuration, context),
|
builder: (context) => _home(configuration, context),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
name: flutter_start
|
name: flutter_start
|
||||||
description: "Flutter_start is a package that allows you to jumpstart your application with a splashScreen, introduction and a home."
|
description: "Flutter_start is a package that allows you to jumpstart your application with a splashScreen, introduction and a home."
|
||||||
publish_to: "none"
|
publish_to: "none"
|
||||||
version: 2.0.1
|
version: 2.0.2
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.2.5 <4.0.0"
|
sdk: ">=3.2.5 <4.0.0"
|
||||||
|
|
Loading…
Reference in a new issue