diff --git a/CHANGELOG.md b/CHANGELOG.md index 4420b29..faeca5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 4.0.0 +- Added default introduction page. +- Added default splash screen. +- Changed the way the splash screen is enabled/disabled. + ## 3.0.0 BREAKING: diff --git a/README.md b/README.md index ac0cf10..8b83abd 100644 --- a/README.md +++ b/README.md @@ -93,13 +93,22 @@ The `StartUserStoryConfiguration` has its own parameters, as specified below: | Parameter | Explanation | |-----------|-------------| | splashScreenBuilder | The builder for the splashScreen. | -| introductionOptions | The options for the introduction. | +| 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. | ## Issues diff --git a/lib/src/models/start_configuration.dart b/lib/src/models/start_configuration.dart index 3533500..b4bc32d 100644 --- a/lib/src/models/start_configuration.dart +++ b/lib/src/models/start_configuration.dart @@ -20,9 +20,10 @@ class StartUserStoryConfiguration { this.minimumSplashScreenDuration = 3, this.splashScreenFuture, this.splashScreenCenterWidget, - this.splashScreenBackgroundColor, + this.splashScreenBackgroundColor = const Color(0xff212121), this.canPopFromIntroduction = true, this.killswitchService, + this.showSplashScreen = true, }); /// You can use this to build your own splash screen. @@ -68,9 +69,6 @@ class StartUserStoryConfiguration { /// Allow popping from introduction, defaults to true final bool canPopFromIntroduction; - /// returns true if the userstory should start with the introduction screen - bool get startWithIntroScreen => - splashScreenBuilder == null && - splashScreenCenterWidget == null && - splashScreenBackgroundColor == null; + /// If the splash screen should be shown or not. + final bool showSplashScreen; } diff --git a/lib/src/user_stories/flutter_start_userstory_go_router.dart b/lib/src/user_stories/flutter_start_userstory_go_router.dart index 23c367e..5baa917 100644 --- a/lib/src/user_stories/flutter_start_userstory_go_router.dart +++ b/lib/src/user_stories/flutter_start_userstory_go_router.dart @@ -11,7 +11,8 @@ import 'package:flutter_start/src/go_router.dart'; import 'package:flutter_start/src/models/start_configuration.dart'; import 'package:flutter_start/src/routes.dart'; import 'package:flutter_start/src/services/killswitch_service.dart'; - +import 'package:flutter_start/src/widgets/default_introduction_options.dart'; +import 'package:flutter_start/src/widgets/default_splash_screen.dart'; import 'package:go_router/go_router.dart'; List getStartStoryRoutes( @@ -84,7 +85,7 @@ List getStartStoryRoutes( body: Center( child: configuration.splashScreenCenterWidget?.call(context) ?? - const SizedBox.shrink(), + defaultSplashScreen, ), ), ); @@ -104,7 +105,7 @@ List getStartStoryRoutes( ); }, options: configuration.introductionOptionsBuilder?.call(context) ?? - const IntroductionOptions(), + defaultIntroductionOptions, physics: configuration.introductionScrollPhysics, child: configuration.introductionFallbackScreen, ); diff --git a/lib/src/user_stories/flutter_start_userstory_navigator.dart b/lib/src/user_stories/flutter_start_userstory_navigator.dart index 4133ff9..b0073dd 100644 --- a/lib/src/user_stories/flutter_start_userstory_navigator.dart +++ b/lib/src/user_stories/flutter_start_userstory_navigator.dart @@ -3,6 +3,8 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_start/flutter_start.dart'; import 'package:flutter_start/src/services/killswitch_service.dart'; +import 'package:flutter_start/src/widgets/default_introduction_options.dart'; +import 'package:flutter_start/src/widgets/default_splash_screen.dart'; /// Initial screen of the user story. /// @@ -19,7 +21,7 @@ class NavigatorStartUserStory extends StatelessWidget { @override Widget build(BuildContext context) { - if (configuration.startWithIntroScreen) { + if (!configuration.showSplashScreen) { return _introduction(configuration, context, onComplete); } @@ -49,7 +51,7 @@ Future startNavigatorUserStory( ), ); - if (configuration.startWithIntroScreen) { + if (!configuration.showSplashScreen && configuration.showIntroduction) { initialRoute = MaterialPageRoute( builder: (context) => _introduction( configuration, @@ -131,7 +133,7 @@ Widget _splashScreen( backgroundColor: configuration.splashScreenBackgroundColor, body: Center( child: configuration.splashScreenCenterWidget?.call(context) ?? - const SizedBox.shrink(), + defaultSplashScreen, ), ); } @@ -152,14 +154,18 @@ Widget _introduction( IntroductionService(SharedPreferencesIntroductionDataProvider()), navigateTo: () async => onComplete(context), options: configuration.introductionOptionsBuilder?.call(context) ?? - const IntroductionOptions(), + defaultIntroductionOptions, physics: configuration.introductionScrollPhysics, child: configuration.introductionFallbackScreen, ); return PopScope( canPop: configuration.canPopFromIntroduction, - child: Scaffold( - body: introduction, - ), + child: configuration.introductionBuilder?.call( + context, + introduction, + ) ?? + Scaffold( + body: introduction, + ), ); } diff --git a/lib/src/widgets/default_introduction_options.dart b/lib/src/widgets/default_introduction_options.dart new file mode 100644 index 0000000..440b0bd --- /dev/null +++ b/lib/src/widgets/default_introduction_options.dart @@ -0,0 +1,146 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_start/flutter_start.dart'; + +IntroductionOptions defaultIntroductionOptions = IntroductionOptions( + introductionTranslations: const IntroductionTranslations( + finishButton: 'Get Started', + nextButton: 'Next', + previousButton: 'Previous', + ), + buttonMode: IntroductionScreenButtonMode.text, + indicatorMode: IndicatorMode.dot, + buttonBuilder: (p0, p1, p2, p3) => defaultIntroductionButton(p0, p1, p2), + introductionButtonTextstyles: defaultIntroductionButtonTextstyles, + pages: defaultIntroductionPages, +); + +const titleStyle = TextStyle( + color: Color(0xff71C6D1), + fontSize: 24, + fontWeight: FontWeight.w700, +); + +final defaultIntroductionPages = [ + IntroductionPage( + decoration: const BoxDecoration( + color: Color(0xffFAF9F6), + ), + title: const Column( + children: [ + SizedBox(height: 100), + Text('welcome to iconinstagram', style: titleStyle), + SizedBox(height: 6), + Text( + 'Welcome to the world of Instagram, where creativity' + ' knows no bounds and connections are made' + ' through captivating visuals.', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w400, + ), + textAlign: TextAlign.center, + ), + ], + ), + text: const Text(''), + ), + IntroductionPage( + decoration: const BoxDecoration( + color: Color(0xffFAF9F6), + ), + title: const Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(height: 100), + Text( + 'discover iconinstagram', + style: titleStyle, + ), + SizedBox(height: 6), + Text( + 'Dive into the vibrant world of' + ' Instagram and discover endless possibilities.' + ' From stunning photography to engaging videos,' + ' Instagram offers a diverse range of content to explore and enjoy.', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w400, + ), + textAlign: TextAlign.center, + ), + ], + ), + text: const Text(''), + ), + IntroductionPage( + decoration: const BoxDecoration( + color: Color(0xffFAF9F6), + ), + title: const Column( + children: [ + SizedBox(height: 100), + Text( + 'elevate your experience', + style: titleStyle, + ), + SizedBox(height: 6), + Text( + 'Whether promoting your business, or connecting' + ' with friends and family, Instagram provides the' + ' tools and platform to make your voice heard.', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w400, + ), + textAlign: TextAlign.center, + ), + ], + ), + text: const Text(''), + ), +]; + +const defaultIntroductionButtonTextstyles = IntroductionButtonTextstyles( + finishButtonStyle: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + ), + nextButtonStyle: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + ), + previousButtonStyle: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + ), + skipButtonStyle: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + ), +); + +Widget defaultIntroductionButton( + BuildContext context, + void Function() onTap, + Widget buttonWidget, +) => + InkWell( + onTap: onTap, + child: Container( + width: 180, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + border: Border.all( + color: const Color( + 0xff979797, + ), + ), + ), + child: Center( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 2.0), + child: buttonWidget, + ), + ), + ), + ); diff --git a/lib/src/widgets/default_splash_screen.dart b/lib/src/widgets/default_splash_screen.dart new file mode 100644 index 0000000..63e1ed6 --- /dev/null +++ b/lib/src/widgets/default_splash_screen.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +const defaultSplashScreen = Text( + 'Splash Screen', + style: TextStyle( + color: Color(0xff71C6D1), + fontWeight: FontWeight.w800, + fontSize: 32, + ), +); diff --git a/pubspec.yaml b/pubspec.yaml index 511c569..b965bf3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: 3.0.0 +version: 4.0.0 environment: sdk: ">=3.2.5 <4.0.0"