mirror of
https://github.com/Iconica-Development/flutter_start.git
synced 2025-05-18 18:13:45 +02:00
fix: feedback on userstory
This commit is contained in:
parent
e7419bc8c1
commit
84e629d5b2
8 changed files with 85 additions and 117 deletions
|
@ -1,3 +1,8 @@
|
|||
## 4.1.0
|
||||
- Updated README
|
||||
- Removed check if the introductions should be shown.
|
||||
- Updated flutter_introduction to 3.1.0
|
||||
|
||||
## 4.0.0
|
||||
- Added default introduction page.
|
||||
- Added default splash screen.
|
||||
|
|
103
README.md
103
README.md
|
@ -6,57 +6,62 @@ Flutter_start is a package that allows you to jumpstart your application with a
|
|||
|
||||
To use this package, add flutter_start as a dependency in your pubspec.yaml file:
|
||||
|
||||
```
|
||||
```yaml
|
||||
flutter_start:
|
||||
git:
|
||||
url: https://github.com/Iconica-Development/flutter_start
|
||||
ref: <Version>
|
||||
ref: 4.1.0
|
||||
```
|
||||
|
||||
To use the module within your Flutter-application with predefined `Go_router` routes you should add the following:
|
||||
## go_router
|
||||
|
||||
Add `go_router` as dependency to your project.
|
||||
|
||||
Add go_router as dependency to your project.
|
||||
Add the following configuration to your flutter_application:
|
||||
|
||||
```
|
||||
StartUserStoryConfiguration startUserStoryConfiguration = const StartUserStoryConfiguration();
|
||||
List<GoRoute> getStartStoryRoutes() => getStartStoryRoutes();
|
||||
```
|
||||
|
||||
and set the values as you wish.
|
||||
Or with options:
|
||||
|
||||
Next add the `StartUserStoryConfiguration` to `getStartStoryRoutes` Like so:
|
||||
Place the following code somewhere in your project where it can be accessed globally:
|
||||
|
||||
```
|
||||
List<GoRoute> getStartRoutes() => getStartStoryRoutes(
|
||||
startUserStoryConfiguration,
|
||||
var startUserStoryConfiguration = const StartUserStoryConfiguration();
|
||||
```
|
||||
|
||||
```
|
||||
List<GoRoute> getStartStoryRoutes() => getStartStoryRoutes(
|
||||
configuration: startUserStoryConfiguration,
|
||||
);
|
||||
```
|
||||
|
||||
Finally add the `getStartRoutes` to your `Go_router` routes like so:
|
||||
Finally add the `getStartRoutes` to your `go_router` routes like so:
|
||||
|
||||
```
|
||||
final GoRouter _router = GoRouter(
|
||||
routes: <RouteBase>[
|
||||
...getStartRoutes()
|
||||
...getStartStoryRoutes()
|
||||
],
|
||||
);
|
||||
```
|
||||
|
||||
The routes that can be used to navigate are:
|
||||
|
||||
For routing to the `SplashScreen`:
|
||||
For routing to the `splashScreen`:
|
||||
|
||||
```
|
||||
static const String splashScreen = '/splashScreen';
|
||||
```
|
||||
|
||||
For routing to the `Introduction`:
|
||||
For routing to the `introduction`:
|
||||
|
||||
```
|
||||
static const String introduction = '/introduction';
|
||||
```
|
||||
|
||||
For routing to the `HomeEntry`:
|
||||
For routing to the `home`:
|
||||
|
||||
```
|
||||
static const String home = '/home';
|
||||
|
@ -73,42 +78,64 @@ final GoRouter _router = GoRouter(
|
|||
);
|
||||
```
|
||||
|
||||
To use the module within your Flutter-application without predefined `Go_router` routes but with `Navigator` routes add the following :
|
||||
|
||||
Add the following configuration to your flutter_application:
|
||||
## Navigator
|
||||
|
||||
Add the following code to the build-method of a chosen widget like so:
|
||||
```
|
||||
StartUserStoryConfiguration startUserStoryConfiguration = const StartUserStoryConfiguration();
|
||||
class Example extends StatelessWidget {
|
||||
const Example({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return NavigatorStartUserStory(
|
||||
onComplete: (context) {},
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Add the following code to the build-method of a chosen widget:
|
||||
or with options:
|
||||
|
||||
Place the following code somewhere in your project where it can be accessed globally:
|
||||
|
||||
```
|
||||
startNavigatorUserStory(startUserStoryConfiguration, context);
|
||||
var startUserStoryConfiguration = const StartUserStoryConfiguration();
|
||||
```
|
||||
|
||||
If the splashScreenBuilder is not used the SplashScreen will be skipped.
|
||||
```
|
||||
class Example extends StatelessWidget {
|
||||
const Example({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return NavigatorStartUserStory(
|
||||
configuration: startUserStoryConfiguration,
|
||||
onComplete: (context) {},
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `StartUserStoryConfiguration` has its own parameters, as specified below:
|
||||
| Parameter | Explanation |
|
||||
|-----------|-------------|
|
||||
| splashScreenBuilder | The builder for the splashScreen. |
|
||||
| introductionBuilder | The builder for the introduction. |
|
||||
| introductionOptionsBuilder | The options for the introduction. |
|
||||
| introductionService | The service for the introduction. Default IntroductionService (SharedPreferencesIntroductionDataProvider()) |
|
||||
| homeEntry | The widget that will be shown after the introduction. |
|
||||
| homeScreenRoute | The route that will be shown after the introduction when using gorouter |
|
||||
| introductionFallbackScreen | The widget that will be shown when the introduction is skipped. |
|
||||
| introductionScrollPhysics | The scrollPhysics for the introduction. |
|
||||
| showIntroduction | Whether or not the introduction should be shown. |
|
||||
| useKillswitch | Whether or not the killswitch should be used. This will only work when you use the splashScreen and you need to have a active internet connection|
|
||||
| minimumSplashScreenDuration | The minimum duration the splashScreen should be shown. |
|
||||
| splashScreenFuture | The future that will be awaited before the splashScreen is closed. |
|
||||
| splashScreenCenterWidget | The widget that will be shown in the center of the splashScreen. |
|
||||
| splashScreenBackgroundColor | The background color of the splashScreen. |
|
||||
| canPopFromIntroduction | Whether or not the introduction can be popped. |
|
||||
| killswitchService | The service for the killswitch. Instead of the default service |
|
||||
| showSplashScreen | Whether or not the splashScreen should be shown. |
|
||||
| `splashScreenBuilder` | The builder to override the default splashScreen |
|
||||
| `introductionBuilder` | A builder to wrap the introductions in your own page |
|
||||
| `introductionOptionsBuilder` | The builder to override the default `introductionOptions` |
|
||||
|`introductionService` | The service to override the default `introductionService` |
|
||||
| `homeScreenRoute` | The route to navigate to after the introduction or splashScreen is completed |
|
||||
| `introductionFallbackScreen` | The screen that is shown when something goes wrong fetching data for the introduction |
|
||||
| `introductionScrollPhysics` | The scroll physics for the introduction |
|
||||
| `showIntroduction` | A boolean to show the introduction or not. Defaults to true |
|
||||
| `useKillswitch` | A boolean to use the killswitch or not. Defaults to false |
|
||||
| `minimumSplashScreenDuration` | The minimum duration the splashScreen should be shown. Defaults to 3 seconds |
|
||||
| `splashScreenFuture` | The future to be completed before the splashScreen is completed |
|
||||
| `splashScreenCenterWidget` | The widget to be shown in the center of the splashScreen |
|
||||
| `splashScreenBackgroundColor` | The color of the splashScreen background. Defaults to Color(0xff212121) |
|
||||
| `canPopFromIntroduction` | Allow popping from introduction, defaults to true. Defaults to true |
|
||||
| `killswitchService` | The service to override the default killswitch service |
|
||||
| `showSplashScreen` | A boolean to show the splashScreen or not. Defaults to true |
|
||||
|
||||
|
||||
## Issues
|
||||
|
||||
|
|
|
@ -39,38 +39,6 @@ StartUserStoryConfiguration config = StartUserStoryConfiguration(
|
|||
splashScreenBuilder: (context, onFinish) => SplashScreen(
|
||||
onFinish: onFinish,
|
||||
),
|
||||
introductionOptionsBuilder: (ctx) => IntroductionOptions(
|
||||
pages: [
|
||||
const IntroductionPage(
|
||||
title: Text('First page'),
|
||||
text: Text('Wow a page'),
|
||||
graphic: FlutterLogo(),
|
||||
),
|
||||
const IntroductionPage(
|
||||
title: Text('Second page'),
|
||||
text: Text('Another page'),
|
||||
graphic: FlutterLogo(),
|
||||
),
|
||||
const IntroductionPage(
|
||||
title: Text('Third page'),
|
||||
text: Text('The final page of this app'),
|
||||
graphic: FlutterLogo(),
|
||||
),
|
||||
],
|
||||
introductionTranslations: const IntroductionTranslations(
|
||||
skipButton: 'Skip it!',
|
||||
nextButton: 'Next',
|
||||
previousButton: 'Previous',
|
||||
finishButton: 'To the app!',
|
||||
),
|
||||
tapEnabled: true,
|
||||
displayMode: IntroductionDisplayMode.multiPageHorizontal,
|
||||
buttonMode: IntroductionScreenButtonMode.text,
|
||||
indicatorMode: IndicatorMode.dash,
|
||||
skippable: true,
|
||||
buttonBuilder: (context, onPressed, child, type) =>
|
||||
ElevatedButton(onPressed: onPressed, child: child),
|
||||
),
|
||||
);
|
||||
|
||||
class SplashScreen extends StatefulWidget {
|
||||
|
@ -114,17 +82,3 @@ class HomeEntry extends StatelessWidget {
|
|||
body: const Center(child: Text('HomeEntry')),
|
||||
);
|
||||
}
|
||||
|
||||
class ExampleIntroductionDataProvider
|
||||
implements SharedPreferencesIntroductionDataProvider {
|
||||
@override
|
||||
String key = 'example';
|
||||
|
||||
@override
|
||||
Future<void> setCompleted({bool value = true}) async =>
|
||||
// ignore: void_checks
|
||||
false;
|
||||
|
||||
@override
|
||||
Future<bool> shouldShow() async => true;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ dependencies:
|
|||
flutter_introduction_shared_preferences:
|
||||
git:
|
||||
url: https://github.com/Iconica-Development/flutter_introduction
|
||||
ref: 3.0.0
|
||||
ref: 3.1.0
|
||||
path: packages/flutter_introduction_shared_preferences
|
||||
|
||||
dev_dependencies:
|
||||
|
|
|
@ -24,7 +24,6 @@ List<GoRoute> getStartStoryRoutes({
|
|||
pageBuilder: (context, state) {
|
||||
var go = context.go;
|
||||
var isAllowedToPassThrough = false;
|
||||
var introductionSeen = false;
|
||||
String? routeAfterSplash;
|
||||
Future<void> splashLoadingMethod() async {
|
||||
await Future.wait<void>(
|
||||
|
@ -40,11 +39,6 @@ List<GoRoute> getStartStoryRoutes({
|
|||
await killswitchService.isKillswitchActive();
|
||||
}
|
||||
|
||||
var introService = configuration.introductionService ??
|
||||
IntroductionService(
|
||||
SharedPreferencesIntroductionDataProvider(),
|
||||
);
|
||||
introductionSeen = !await introService.shouldShow();
|
||||
if (context.mounted)
|
||||
routeAfterSplash = await configuration.splashScreenFuture
|
||||
?.call(context) ??
|
||||
|
@ -62,7 +56,7 @@ List<GoRoute> getStartStoryRoutes({
|
|||
|
||||
if (configuration.useKillswitch && isAllowedToPassThrough) return;
|
||||
|
||||
if (!configuration.showIntroduction || introductionSeen) {
|
||||
if ((!configuration.showIntroduction) && context.mounted) {
|
||||
return go(
|
||||
routeAfterSplash ?? StartUserStoryRoutes.home,
|
||||
);
|
||||
|
@ -85,7 +79,7 @@ List<GoRoute> getStartStoryRoutes({
|
|||
body: Center(
|
||||
child:
|
||||
configuration.splashScreenCenterWidget?.call(context) ??
|
||||
defaultSplashScreen,
|
||||
defaultSplashScreen(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -71,7 +71,6 @@ Widget _splashScreen(
|
|||
var navigator = Navigator.of(context);
|
||||
|
||||
var isAllowedToPassThrough = false;
|
||||
var introductionSeen = false;
|
||||
|
||||
Future<void> splashHandler() async {
|
||||
await Future.wait<void>(
|
||||
|
@ -87,12 +86,6 @@ Widget _splashScreen(
|
|||
isAllowedToPassThrough =
|
||||
await killswitchService.isKillswitchActive();
|
||||
}
|
||||
|
||||
var introService = configuration.introductionService ??
|
||||
IntroductionService(
|
||||
SharedPreferencesIntroductionDataProvider(),
|
||||
);
|
||||
introductionSeen = !await introService.shouldShow();
|
||||
},
|
||||
),
|
||||
Future.delayed(
|
||||
|
@ -105,8 +98,7 @@ Widget _splashScreen(
|
|||
|
||||
if (configuration.useKillswitch && isAllowedToPassThrough) return;
|
||||
|
||||
if ((!configuration.showIntroduction || introductionSeen) &&
|
||||
context.mounted) {
|
||||
if ((!configuration.showIntroduction) && context.mounted) {
|
||||
onComplete(context);
|
||||
return;
|
||||
}
|
||||
|
@ -132,7 +124,7 @@ Widget _splashScreen(
|
|||
backgroundColor: configuration.splashScreenBackgroundColor,
|
||||
body: Center(
|
||||
child: configuration.splashScreenCenterWidget?.call(context) ??
|
||||
defaultSplashScreen,
|
||||
defaultSplashScreen(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
const defaultSplashScreen = Text(
|
||||
'Splash Screen',
|
||||
style: TextStyle(
|
||||
color: Color(0xff71C6D1),
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 32,
|
||||
),
|
||||
Text defaultSplashScreen(BuildContext context) => Text(
|
||||
'iconinstagram',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
);
|
||||
|
|
|
@ -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: 4.0.0
|
||||
version: 4.1.0
|
||||
|
||||
environment:
|
||||
sdk: ">=3.2.5 <4.0.0"
|
||||
|
@ -16,12 +16,12 @@ dependencies:
|
|||
flutter_introduction:
|
||||
git:
|
||||
url: https://github.com/Iconica-Development/flutter_introduction
|
||||
ref: 3.0.0
|
||||
ref: 3.1.0
|
||||
path: packages/flutter_introduction
|
||||
flutter_introduction_shared_preferences:
|
||||
git:
|
||||
url: https://github.com/Iconica-Development/flutter_introduction
|
||||
ref: 3.0.0
|
||||
ref: 3.1.0
|
||||
path: packages/flutter_introduction_shared_preferences
|
||||
|
||||
dev_dependencies:
|
||||
|
|
Loading…
Reference in a new issue