diff --git a/CHANGELOG.md b/CHANGELOG.md index eac25cd..02fc3ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 4.0.0 + +* Added Buildcontext to the pages parameter. +* Added `dotColor` so the default can be changed. +* Changed the default `pages` to include theme. + ## 3.1.0 * Introduction now uses `IntroductionScreenMode` to determine how often the introductions should be shown diff --git a/packages/flutter_introduction/example/lib/main.dart b/packages/flutter_introduction/example/lib/main.dart index 2edeb60..2711f5b 100644 --- a/packages/flutter_introduction/example/lib/main.dart +++ b/packages/flutter_introduction/example/lib/main.dart @@ -38,7 +38,7 @@ class _MyHomePageState extends State { Widget build(BuildContext context) => Scaffold( body: Introduction( options: IntroductionOptions( - pages: [ + pages: (context) => [ const IntroductionPage( title: Text('First page'), text: Text('Wow a page'), diff --git a/packages/flutter_introduction/pubspec.yaml b/packages/flutter_introduction/pubspec.yaml index 01afa4e..6547254 100644 --- a/packages/flutter_introduction/pubspec.yaml +++ b/packages/flutter_introduction/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_introduction description: Combined Package of Flutter Introduction Widget and Flutter Introduction Service -version: 3.1.0 +version: 4.0.0 publish_to: none environment: @@ -13,12 +13,12 @@ dependencies: flutter_introduction_widget: git: url: https://github.com/Iconica-Development/flutter_introduction - ref: 3.1.0 + ref: 4.0.0 path: packages/flutter_introduction_widget flutter_introduction_service: git: url: https://github.com/Iconica-Development/flutter_introduction - ref: 3.1.0 + ref: 4.0.0 path: packages/flutter_introduction_service dev_dependencies: diff --git a/packages/flutter_introduction_firebase/lib/src/introduction_widget.dart b/packages/flutter_introduction_firebase/lib/src/introduction_widget.dart index 94905ff..de75a47 100644 --- a/packages/flutter_introduction_firebase/lib/src/introduction_widget.dart +++ b/packages/flutter_introduction_firebase/lib/src/introduction_widget.dart @@ -115,7 +115,7 @@ class _IntroductionState extends State { snapshot.data is List) { return IntroductionScreen( options: widget.options.copyWith( - pages: snapshot.data?.map( + pages: (context) => snapshot.data!.map( (e) { var title = e.title.isEmpty ? '' diff --git a/packages/flutter_introduction_firebase/pubspec.yaml b/packages/flutter_introduction_firebase/pubspec.yaml index 4280a8e..5885175 100644 --- a/packages/flutter_introduction_firebase/pubspec.yaml +++ b/packages/flutter_introduction_firebase/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_introduction_firebase description: Flutter Introduction Page that uses firebase for the pages and some settings -version: 3.1.0 +version: 4.0.0 publish_to: none environment: @@ -15,12 +15,12 @@ dependencies: flutter_introduction_widget: git: url: https://github.com/Iconica-Development/flutter_introduction - ref: 3.1.0 + ref: 4.0.0 path: packages/flutter_introduction_widget flutter_introduction_service: git: url: https://github.com/Iconica-Development/flutter_introduction - ref: 3.1.0 + ref: 4.0.0 path: packages/flutter_introduction_service dev_dependencies: diff --git a/packages/flutter_introduction_interface/pubspec.yaml b/packages/flutter_introduction_interface/pubspec.yaml index 9201487..32c72f9 100644 --- a/packages/flutter_introduction_interface/pubspec.yaml +++ b/packages/flutter_introduction_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_introduction_interface description: A new Flutter package project. -version: 3.1.0 +version: 4.0.0 publish_to: none environment: diff --git a/packages/flutter_introduction_service/pubspec.yaml b/packages/flutter_introduction_service/pubspec.yaml index 9979b50..ba92a33 100644 --- a/packages/flutter_introduction_service/pubspec.yaml +++ b/packages/flutter_introduction_service/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_introduction_service description: A new Flutter package project. -version: 3.1.0 +version: 4.0.0 publish_to: none environment: @@ -13,7 +13,7 @@ dependencies: flutter_introduction_interface: git: url: https://github.com/Iconica-Development/flutter_introduction - ref: 3.1.0 + ref: 4.0.0 path: packages/flutter_introduction_interface dev_dependencies: diff --git a/packages/flutter_introduction_shared_preferences/pubspec.yaml b/packages/flutter_introduction_shared_preferences/pubspec.yaml index a2716b3..e326021 100644 --- a/packages/flutter_introduction_shared_preferences/pubspec.yaml +++ b/packages/flutter_introduction_shared_preferences/pubspec.yaml @@ -1,19 +1,19 @@ name: flutter_introduction_shared_preferences description: A new Flutter package project. -version: 3.1.0 +version: 4.0.0 publish_to: none environment: - sdk: '>=2.18.0 <3.0.0' + sdk: ">=2.18.0 <3.0.0" flutter: ">=1.17.0" dependencies: flutter: sdk: flutter - flutter_introduction_interface: - git: + flutter_introduction_interface: + git: url: https://github.com/Iconica-Development/flutter_introduction - ref: 3.1.0 + ref: 4.0.0 path: packages/flutter_introduction_interface shared_preferences: any diff --git a/packages/flutter_introduction_widget/example/lib/main.dart b/packages/flutter_introduction_widget/example/lib/main.dart index cc9cbb2..678fc22 100644 --- a/packages/flutter_introduction_widget/example/lib/main.dart +++ b/packages/flutter_introduction_widget/example/lib/main.dart @@ -31,7 +31,7 @@ class MyApp extends StatelessWidget { ), home: IntroductionScreen( options: IntroductionOptions( - pages: [ + pages: (context) => [ const IntroductionPage( title: Text('Basic Page'), text: Text( diff --git a/packages/flutter_introduction_widget/lib/src/config/default_introduction_pages.dart b/packages/flutter_introduction_widget/lib/src/config/default_introduction_pages.dart index 4331983..5ab605c 100644 --- a/packages/flutter_introduction_widget/lib/src/config/default_introduction_pages.dart +++ b/packages/flutter_introduction_widget/lib/src/config/default_introduction_pages.dart @@ -1,77 +1,85 @@ - import 'package:flutter/material.dart'; import 'package:flutter_introduction_widget/flutter_introduction_widget.dart'; -const List defaultIntroductionPages = [ - IntroductionPage( - title: Column( - children: [ - SizedBox(height: 50), - Text( - 'welcome to iconinstagram', +List defaultIntroductionPages(BuildContext context) { + var theme = Theme.of(context); + return [ + IntroductionPage( + title: Column( + children: [ + const SizedBox(height: 50), + Text( + 'welcome to iconinstagram', + style: theme.textTheme.headlineLarge, + ), + const SizedBox(height: 6), + ], + ), + graphic: const Image( + image: AssetImage( + 'assets/first.png', + package: 'flutter_introduction_widget', ), - SizedBox(height: 6), - ], - ), - graphic: Image( - image: AssetImage( - 'assets/first.png', - package: 'flutter_introduction_widget', + ), + text: Text( + 'Welcome to the world of Instagram, where creativity' + ' knows no bounds and connections are made' + ' through captivating visuals.', + textAlign: TextAlign.center, + style: theme.textTheme.bodyMedium, ), ), - text: Text( - 'Welcome to the world of Instagram, where creativity' - ' knows no bounds and connections are made' - ' through captivating visuals.', - textAlign: TextAlign.center, - ), - ), - IntroductionPage( - title: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox(height: 50), - Text( - 'discover iconinstagram', + IntroductionPage( + title: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const SizedBox(height: 50), + Text( + 'discover iconinstagram', + style: theme.textTheme.headlineLarge, + ), + const SizedBox(height: 6), + ], + ), + text: 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.', + textAlign: TextAlign.center, + style: theme.textTheme.bodyMedium, + ), + graphic: const Image( + image: AssetImage( + 'assets/second.png', + package: 'flutter_introduction_widget', ), - SizedBox(height: 6), - ], - ), - text: 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.', - textAlign: TextAlign.center, - ), - graphic: Image( - image: AssetImage( - 'assets/second.png', - package: 'flutter_introduction_widget', ), ), - ), - IntroductionPage( - title: Column( - children: [ - SizedBox(height: 50), - Text( - 'elevate your experience', + IntroductionPage( + title: Column( + children: [ + const SizedBox(height: 50), + Text( + 'elevate your experience', + style: theme.textTheme.headlineLarge, + ), + const SizedBox(height: 6), + ], + ), + graphic: const Image( + image: AssetImage( + 'assets/third.png', + package: 'flutter_introduction_widget', ), - SizedBox(height: 6), - ], - ), - graphic: Image( - image: AssetImage( - 'assets/third.png', - package: 'flutter_introduction_widget', + ), + text: Text( + 'Whether promoting your business, or connecting' + ' with friends and family, Instagram provides the' + ' tools and platform to make your voice heard.', + textAlign: TextAlign.center, + style: theme.textTheme.bodyMedium, ), ), - text: Text( - 'Whether promoting your business, or connecting' - ' with friends and family, Instagram provides the' - ' tools and platform to make your voice heard.', - textAlign: TextAlign.center, - ), - ), -]; + ]; +} diff --git a/packages/flutter_introduction_widget/lib/src/config/introduction.dart b/packages/flutter_introduction_widget/lib/src/config/introduction.dart index 47d6127..8f35ca5 100644 --- a/packages/flutter_introduction_widget/lib/src/config/introduction.dart +++ b/packages/flutter_introduction_widget/lib/src/config/introduction.dart @@ -75,6 +75,7 @@ class IntroductionOptions { this.controlMode = IntroductionControlMode.previousNextButton, this.dotSize = 12, this.dotSpacing = 24, + this.dotColor, }) : assert( !(identical(indicatorMode, IndicatorMode.custom) && indicatorBuilder == null), @@ -95,7 +96,7 @@ class IntroductionOptions { /// List of introduction pages to set the text, icons or images for the /// introduction screens. - final List pages; + final List Function(BuildContext context) pages; /// Determines whether the user can tap the screen to go to the next /// introduction screen. @@ -212,9 +213,13 @@ class IntroductionOptions { /// The distance between the center of each dot. Default is 24 final double dotSpacing; + /// The color of the dots in the indicator. Default is the primary color of + /// the theme + final Color? dotColor; + IntroductionOptions copyWith({ IntroductionScreenMode? mode, - List? pages, + List Function(BuildContext context)? pages, bool? tapEnabled, IntroductionScreenButtonMode? buttonMode, IntroductionLayoutStyle? layoutStyle, @@ -269,22 +274,10 @@ class IntroductionTranslations { class IntroductionButtonTextstyles { const IntroductionButtonTextstyles({ - this.skipButtonStyle = const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - ), - this.nextButtonStyle = const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - ), - this.previousButtonStyle = const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - ), - this.finishButtonStyle = const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - ), + this.skipButtonStyle, + this.nextButtonStyle, + this.previousButtonStyle, + this.finishButtonStyle, }); final TextStyle? skipButtonStyle; final TextStyle? nextButtonStyle; diff --git a/packages/flutter_introduction_widget/lib/src/types/page_introduction.dart b/packages/flutter_introduction_widget/lib/src/types/page_introduction.dart index 8ea8a46..2fde74f 100644 --- a/packages/flutter_introduction_widget/lib/src/types/page_introduction.dart +++ b/packages/flutter_introduction_widget/lib/src/types/page_introduction.dart @@ -77,7 +77,7 @@ class _MultiPageIntroductionScreenState @override Widget build(BuildContext context) { - var pages = widget.options.pages; + var pages = widget.options.pages.call(context); var translations = widget.options.introductionTranslations; return Stack( children: [ @@ -150,6 +150,7 @@ class _MultiPageIntroductionScreenState AnimatedBuilder( animation: _currentPage, builder: (context, _) => Indicator( + options: widget.options, indicatorBuilder: widget.options.indicatorBuilder, mode: widget.options.indicatorMode, controller: _controller, @@ -341,6 +342,7 @@ class IntroductionTwoButtons extends StatelessWidget { var translations = options.introductionTranslations; var showFinishButton = options.buttonMode == IntroductionScreenButtonMode.singleFinish; + var theme = Theme.of(context); return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -362,7 +364,8 @@ class IntroductionTwoButtons extends StatelessWidget { Text( translations.previousButton, style: options.introductionButtonTextstyles - .previousButtonStyle, + .previousButtonStyle ?? + theme.textTheme.bodyMedium, ), IntroductionButtonType.previous, ) ?? @@ -384,7 +387,8 @@ class IntroductionTwoButtons extends StatelessWidget { child: Text( translations.previousButton, style: options.introductionButtonTextstyles - .previousButtonStyle, + .previousButtonStyle ?? + theme.textTheme.bodyMedium, ), ), ), @@ -408,8 +412,9 @@ class IntroductionTwoButtons extends StatelessWidget { _next, Text( translations.nextButton, - style: options - .introductionButtonTextstyles.nextButtonStyle, + style: options.introductionButtonTextstyles + .nextButtonStyle ?? + theme.textTheme.bodyMedium, ), IntroductionButtonType.next, ) ?? @@ -430,7 +435,8 @@ class IntroductionTwoButtons extends StatelessWidget { child: Text( translations.nextButton, style: options.introductionButtonTextstyles - .nextButtonStyle, + .nextButtonStyle ?? + theme.textTheme.bodyMedium, ), ), ), @@ -454,8 +460,9 @@ class IntroductionTwoButtons extends StatelessWidget { }, Text( translations.finishButton, - style: options - .introductionButtonTextstyles.finishButtonStyle, + style: options.introductionButtonTextstyles + .finishButtonStyle ?? + theme.textTheme.bodyMedium, ), IntroductionButtonType.finish, ) ?? @@ -478,7 +485,8 @@ class IntroductionTwoButtons extends StatelessWidget { child: Text( translations.finishButton, style: options.introductionButtonTextstyles - .finishButtonStyle, + .finishButtonStyle ?? + theme.textTheme.bodyMedium, ), ), ), @@ -512,8 +520,9 @@ class IntroductionTwoButtons extends StatelessWidget { }, Text( translations.finishButton, - style: options - .introductionButtonTextstyles.finishButtonStyle, + style: options.introductionButtonTextstyles + .finishButtonStyle ?? + theme.textTheme.bodyMedium, ), IntroductionButtonType.finish, ) ?? @@ -537,7 +546,8 @@ class IntroductionTwoButtons extends StatelessWidget { child: Text( translations.finishButton, style: options.introductionButtonTextstyles - .finishButtonStyle, + .finishButtonStyle ?? + theme.textTheme.bodyMedium, ), ), ), diff --git a/packages/flutter_introduction_widget/lib/src/widgets/indicator.dart b/packages/flutter_introduction_widget/lib/src/widgets/indicator.dart index 3fc4729..965f526 100644 --- a/packages/flutter_introduction_widget/lib/src/widgets/indicator.dart +++ b/packages/flutter_introduction_widget/lib/src/widgets/indicator.dart @@ -17,6 +17,7 @@ class Indicator extends StatelessWidget { required this.indicatorBuilder, required this.dotSize, required this.dotSpacing, + required this.options, super.key, }) : assert( !(mode == IndicatorMode.custom && indicatorBuilder == null), @@ -46,6 +47,8 @@ class Indicator extends StatelessWidget { /// The distance between the center of each dot. final double dotSpacing; + final IntroductionOptions options; + @override Widget build(BuildContext context) { var theme = Theme.of(context); @@ -57,7 +60,7 @@ class Indicator extends StatelessWidget { dotSize: dotSize, dotSpacing: dotSpacing, controller: controller, - color: theme.colorScheme.secondary, + color: options.dotColor ?? theme.colorScheme.primary, itemCount: count, onPageSelected: (int page) { unawaited( @@ -73,7 +76,7 @@ class Indicator extends StatelessWidget { return DashIndicator( color: theme.colorScheme.primary, controller: controller, - selectedColor: theme.colorScheme.primary, + selectedColor: options.dotColor ?? theme.colorScheme.primary, itemCount: count, onPageSelected: (int page) { unawaited( diff --git a/packages/flutter_introduction_widget/pubspec.yaml b/packages/flutter_introduction_widget/pubspec.yaml index 04cded5..ad47c5c 100644 --- a/packages/flutter_introduction_widget/pubspec.yaml +++ b/packages/flutter_introduction_widget/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_introduction_widget description: Flutter Introduction Widget for showing a list of introduction pages on a single scrollable page or horizontal pageview -version: 3.1.0 +version: 4.0.0 homepage: https://github.com/Iconica-Development/flutter_introduction_widget environment: diff --git a/pubspec.yaml b/pubspec.yaml index e31402e..3b59e21 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: flutter_introduction_workspace -version: 3.1.0 +version: 4.0.0 environment: sdk: '>=3.1.0 <4.0.0'