From 0ef937ad8b87888f43e07b4eb46457639297eae6 Mon Sep 17 00:00:00 2001 From: Freek van de Ven Date: Tue, 30 Jan 2024 16:51:58 +0100 Subject: [PATCH] feat: add option for styling introductionbutton texts --- CHANGELOG.md | 5 + melos.yaml | 3 + .../flutter_introduction/example/pubspec.yaml | 6 +- packages/flutter_introduction/pubspec.yaml | 7 +- .../pubspec.yaml | 6 +- .../pubspec.yaml | 3 +- .../flutter_introduction_service/pubspec.yaml | 5 +- .../pubspec.yaml | 5 +- .../example/pubspec.yaml | 2 +- .../lib/src/config/introduction.dart | 70 +++++++++----- .../lib/src/types/page_introduction.dart | 92 +++++++++++++++---- .../flutter_introduction_widget/pubspec.yaml | 3 +- pubspec.yaml | 2 +- 13 files changed, 147 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25fcb3a..97f796f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.1.0 + +* Upgrade dependencies +* Add introductionButtonTextstyles option to IntroductionOptions for styling the introduction button text + ## 2.0.0 * Initial release of working flutter_introduction mono project. diff --git a/melos.yaml b/melos.yaml index 2280b71..1054152 100644 --- a/melos.yaml +++ b/melos.yaml @@ -19,6 +19,9 @@ scripts: upgrade: run: melos exec -c 1 -- "flutter pub upgrade" + + upgrade-major: + run: melos exec -c 1 -- "flutter pub upgrade --major-versions" create: # run create in the example folder of flutter_introduction, flutter_introduction_firebase diff --git a/packages/flutter_introduction/example/pubspec.yaml b/packages/flutter_introduction/example/pubspec.yaml index 78642e3..40b46dc 100644 --- a/packages/flutter_introduction/example/pubspec.yaml +++ b/packages/flutter_introduction/example/pubspec.yaml @@ -17,15 +17,11 @@ dependencies: flutter_introduction: path: ../ flutter_introduction_shared_preferences: - git: - url: https://github.com/Iconica-Development/flutter_introduction - ref: 2.0.0 - path: packages/flutter_introduction_shared_preferences + path: ../../flutter_introduction_shared_preferences dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 flutter_iconica_analysis: git: url: https://github.com/Iconica-Development/flutter_iconica_analysis diff --git a/packages/flutter_introduction/pubspec.yaml b/packages/flutter_introduction/pubspec.yaml index 91939be..7237226 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: 2.0.0 +version: 2.1.0 publish_to: none environment: @@ -13,18 +13,17 @@ dependencies: flutter_introduction_widget: git: url: https://github.com/Iconica-Development/flutter_introduction - ref: 2.0.0 + ref: 2.1.0 path: packages/flutter_introduction_widget flutter_introduction_service: git: url: https://github.com/Iconica-Development/flutter_introduction - ref: 2.0.0 + ref: 2.1.0 path: packages/flutter_introduction_service dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 flutter_iconica_analysis: git: url: https://github.com/Iconica-Development/flutter_iconica_analysis diff --git a/packages/flutter_introduction_firebase/pubspec.yaml b/packages/flutter_introduction_firebase/pubspec.yaml index fc69ef3..cd4b126 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: 2.0.0 +version: 2.1.0 publish_to: none environment: @@ -15,12 +15,12 @@ dependencies: flutter_introduction_widget: git: url: https://github.com/Iconica-Development/flutter_introduction - ref: 2.0.0 + ref: 2.1.0 path: packages/flutter_introduction_widget flutter_introduction_service: git: url: https://github.com/Iconica-Development/flutter_introduction - ref: 2.0.0 + ref: 2.1.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 771c5f7..645fd0c 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: 2.0.0 +version: 2.1.0 publish_to: none environment: @@ -18,7 +18,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 flutter_iconica_analysis: git: url: https://github.com/Iconica-Development/flutter_iconica_analysis diff --git a/packages/flutter_introduction_service/pubspec.yaml b/packages/flutter_introduction_service/pubspec.yaml index 8043c0c..8376320 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: 2.0.0 +version: 2.1.0 publish_to: none environment: @@ -13,13 +13,12 @@ dependencies: flutter_introduction_interface: git: url: https://github.com/Iconica-Development/flutter_introduction - ref: 2.0.0 + ref: 2.1.0 path: packages/flutter_introduction_interface dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 flutter_iconica_analysis: git: url: https://github.com/Iconica-Development/flutter_iconica_analysis diff --git a/packages/flutter_introduction_shared_preferences/pubspec.yaml b/packages/flutter_introduction_shared_preferences/pubspec.yaml index 4d643c5..04741d2 100644 --- a/packages/flutter_introduction_shared_preferences/pubspec.yaml +++ b/packages/flutter_introduction_shared_preferences/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_introduction_shared_preferences description: A new Flutter package project. -version: 2.0.0 +version: 2.1.0 publish_to: none environment: @@ -13,14 +13,13 @@ dependencies: flutter_introduction_interface: git: url: https://github.com/Iconica-Development/flutter_introduction - ref: 2.0.0 + ref: 2.1.0 path: packages/flutter_introduction_interface shared_preferences: any dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 flutter_iconica_analysis: git: url: https://github.com/Iconica-Development/flutter_iconica_analysis diff --git a/packages/flutter_introduction_widget/example/pubspec.yaml b/packages/flutter_introduction_widget/example/pubspec.yaml index 861f95e..f19ff96 100644 --- a/packages/flutter_introduction_widget/example/pubspec.yaml +++ b/packages/flutter_introduction_widget/example/pubspec.yaml @@ -18,7 +18,7 @@ dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^3.0.1 flutter: diff --git a/packages/flutter_introduction_widget/lib/src/config/introduction.dart b/packages/flutter_introduction_widget/lib/src/config/introduction.dart index e7b0323..e46bbb8 100644 --- a/packages/flutter_introduction_widget/lib/src/config/introduction.dart +++ b/packages/flutter_introduction_widget/lib/src/config/introduction.dart @@ -59,6 +59,7 @@ class IntroductionPage { class IntroductionOptions { const IntroductionOptions({ this.introductionTranslations = const IntroductionTranslations(), + this.introductionButtonTextstyles = const IntroductionButtonTextstyles(), this.indicatorMode = IndicatorMode.dash, this.indicatorBuilder, this.layoutStyle = IntroductionLayoutStyle.imageCenter, @@ -79,12 +80,12 @@ class IntroductionOptions { ); /// Determine when the introduction screens needs to be shown. - /// + /// /// [IntroductionScreenMode.showNever] To disable introduction screens. - /// + /// /// [IntroductionScreenMode.showAlways] To always show the introduction /// screens on startup. - /// + /// /// [IntroductionScreenMode.showOnce] To only show the introduction screens /// once on startup. final IntroductionScreenMode mode; @@ -101,13 +102,13 @@ class IntroductionOptions { /// introduction screen. /// Introduction screens can always be navigated by swiping (or tapping if /// [tapEnabled] is enabled). - /// + /// /// [IntroductionScreenButtonMode.text] Use text buttons (text can be set by /// setting the translation key or using the default appshell translations). - /// + /// /// [IntroductionScreenButtonMode.icon] Use icon buttons (icons can be /// changed by providing a icon library) - /// + /// /// [IntroductionScreenButtonMode.disabled] Disable buttons. final IntroductionScreenButtonMode buttonMode; @@ -115,21 +116,21 @@ class IntroductionOptions { /// using [pages]. /// Every introduction page provided with a image or icon will use the same /// layout setting. - /// + /// /// [IntroductionLayoutStyle.imageCenter] Image/icon will be at the center of the introduction page. - /// + /// /// [IntroductionLayoutStyle.imageTop] Image/icon will be at the top of the introduction page. - /// + /// /// [IntroductionLayoutStyle.imageBottom] Image/icon will be at the bottom of the introduction page. final IntroductionLayoutStyle layoutStyle; /// Determines the style of the page indicator shown at the bottom on the /// introduction pages. - /// + /// /// [IndicatorMode.dot] Shows a dot for each page. - /// + /// /// [IndicatorMode.dash] Shows a dash for each page. - /// + /// /// [IndicatorMode.custom] calls indicatorBuilder for the indicator final IndicatorMode indicatorMode; @@ -152,23 +153,23 @@ class IntroductionOptions { /// [IntroductionDisplayMode.multiPageHorizontal] Configured introduction /// pages will be shown on seperate screens and can be navigated using using /// buttons (if enabled) or swiping. - /// + /// /// !Unimplemented! [IntroductionDisplayMode.singleScrollablePageVertical] /// All configured introduction pages will be shown on a single scrollable /// page. /// final IntroductionDisplayMode displayMode; - /// When [IntroductionDisplayMode.multiPageHorizontal] is selected multiple + /// When [IntroductionDisplayMode.multiPageHorizontal] is selected multiple /// controlMode can be selected. - /// - /// [IntroductionControlMode.previousNextButton] shows two buttons at the - /// bottom of the screen to return or proceed. The skip button is placed at + /// + /// [IntroductionControlMode.previousNextButton] shows two buttons at the + /// bottom of the screen to return or proceed. The skip button is placed at /// the top left of the screen. - /// - /// [IntroductionControlMode.singleButton] contains one button at the bottom - /// of the screen to proceed. Underneath is clickable text to skip if the - /// current page is the first page. If the current page is any different it + /// + /// [IntroductionControlMode.singleButton] contains one button at the bottom + /// of the screen to proceed. Underneath is clickable text to skip if the + /// current page is the first page. If the current page is any different it /// return to the previous screen. /// final IntroductionControlMode controlMode; @@ -192,6 +193,16 @@ class IntroductionOptions { /// - Finish final IntroductionTranslations introductionTranslations; + /// The textstyles for all buttons on the introductionpages + /// + /// See [IntroductionButtonTextstyles] for more information + /// The following buttons have a textstyle: + /// - Skip + /// - Next + /// - Previous + /// - Finish + final IntroductionButtonTextstyles introductionButtonTextstyles; + IntroductionOptions copyWith({ IntroductionScreenMode? mode, List? pages, @@ -212,6 +223,7 @@ class IntroductionOptions { Widget Function(BuildContext, VoidCallback, Widget, IntroductionButtonType)? buttonBuilder, IntroductionTranslations? introductionTranslations, + IntroductionButtonTextstyles? introductionButtonTextstyles, }) => IntroductionOptions( mode: mode ?? this.mode, @@ -228,10 +240,11 @@ class IntroductionOptions { buttonBuilder: buttonBuilder ?? this.buttonBuilder, introductionTranslations: introductionTranslations ?? this.introductionTranslations, + introductionButtonTextstyles: + introductionButtonTextstyles ?? this.introductionButtonTextstyles, ); } -/// class IntroductionTranslations { const IntroductionTranslations({ this.skipButton = 'skip', @@ -244,3 +257,16 @@ class IntroductionTranslations { final String previousButton; final String finishButton; } + +class IntroductionButtonTextstyles { + const IntroductionButtonTextstyles({ + this.skipButtonStyle, + this.nextButtonStyle, + this.previousButtonStyle, + this.finishButtonStyle, + }); + final TextStyle? skipButtonStyle; + final TextStyle? nextButtonStyle; + final TextStyle? previousButtonStyle; + final TextStyle? finishButtonStyle; +} 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 d16228d..8d2a837 100644 --- a/packages/flutter_introduction_widget/lib/src/types/page_introduction.dart +++ b/packages/flutter_introduction_widget/lib/src/types/page_introduction.dart @@ -326,12 +326,20 @@ class IntroductionTwoButtons extends StatelessWidget { options.buttonBuilder?.call( context, _previous, - Text(translations.previousButton), + Text( + translations.previousButton, + style: options + .introductionButtonTextstyles.previousButtonStyle, + ), IntroductionButtonType.previous, ) ?? TextButton( onPressed: _previous, - child: Text(translations.previousButton), + child: Text( + translations.previousButton, + style: options + .introductionButtonTextstyles.previousButtonStyle, + ), ), ] else const SizedBox.shrink(), @@ -339,12 +347,18 @@ class IntroductionTwoButtons extends StatelessWidget { options.buttonBuilder?.call( context, _next, - Text(translations.nextButton), + Text( + translations.nextButton, + style: options.introductionButtonTextstyles.nextButtonStyle, + ), IntroductionButtonType.next, ) ?? TextButton( onPressed: _next, - child: Text(translations.nextButton), + child: Text( + translations.nextButton, + style: options.introductionButtonTextstyles.nextButtonStyle, + ), ), ] else if (last) ...[ options.buttonBuilder?.call( @@ -352,14 +366,22 @@ class IntroductionTwoButtons extends StatelessWidget { () { onFinish?.call(); }, - Text(translations.finishButton), + Text( + translations.finishButton, + style: + options.introductionButtonTextstyles.finishButtonStyle, + ), IntroductionButtonType.finish, ) ?? TextButton( onPressed: () { onFinish?.call(); }, - child: Text(translations.finishButton), + child: Text( + translations.finishButton, + style: + options.introductionButtonTextstyles.finishButtonStyle, + ), ), ] else ...[ const SizedBox.shrink(), @@ -379,14 +401,22 @@ class IntroductionTwoButtons extends StatelessWidget { () { onFinish?.call(); }, - Text(translations.finishButton), + Text( + translations.finishButton, + style: options + .introductionButtonTextstyles.finishButtonStyle, + ), IntroductionButtonType.finish, ) ?? ElevatedButton( onPressed: () { onFinish?.call(); }, - child: Text(translations.finishButton), + child: Text( + translations.finishButton, + style: options + .introductionButtonTextstyles.finishButtonStyle, + ), ), ), ), @@ -450,37 +480,59 @@ class IntroductionOneButton extends StatelessWidget { () { onFinish?.call(); }, - Text(translations.finishButton), + Text( + translations.finishButton, + style: + options.introductionButtonTextstyles.finishButtonStyle, + ), IntroductionButtonType.finish, ) ?? TextButton( onPressed: () { onFinish?.call(); }, - child: Text(translations.finishButton), + child: Text( + translations.finishButton, + style: + options.introductionButtonTextstyles.finishButtonStyle, + ), ), ] else ...[ options.buttonBuilder?.call( context, _next, - Text(translations.nextButton), + Text( + translations.nextButton, + style: options.introductionButtonTextstyles.nextButtonStyle, + ), IntroductionButtonType.next, ) ?? TextButton( onPressed: _next, - child: Text(translations.nextButton), + child: Text( + translations.nextButton, + style: options.introductionButtonTextstyles.nextButtonStyle, + ), ), ], if (previous) ...[ options.buttonBuilder?.call( context, _previous, - Text(translations.previousButton), + Text( + translations.previousButton, + style: options + .introductionButtonTextstyles.previousButtonStyle, + ), IntroductionButtonType.previous, ) ?? TextButton( onPressed: _previous, - child: Text(translations.previousButton), + child: Text( + translations.previousButton, + style: options + .introductionButtonTextstyles.previousButtonStyle, + ), ), ] else ...[ options.buttonBuilder?.call( @@ -488,14 +540,22 @@ class IntroductionOneButton extends StatelessWidget { () { onFinish?.call(); }, - Text(translations.finishButton), + Text( + translations.finishButton, + style: + options.introductionButtonTextstyles.finishButtonStyle, + ), IntroductionButtonType.skip, ) ?? TextButton( onPressed: () { onFinish?.call(); }, - child: Text(translations.finishButton), + child: Text( + translations.finishButton, + style: + options.introductionButtonTextstyles.finishButtonStyle, + ), ), ], ], diff --git a/packages/flutter_introduction_widget/pubspec.yaml b/packages/flutter_introduction_widget/pubspec.yaml index 2898b38..a1e18e3 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: 2.0.0 +version: 2.1.0 homepage: https://github.com/Iconica-Development/flutter_introduction_widget environment: @@ -14,7 +14,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 flutter_iconica_analysis: git: url: https://github.com/Iconica-Development/flutter_iconica_analysis diff --git a/pubspec.yaml b/pubspec.yaml index fcb35c8..45f886a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: flutter_introduction_workspace -version: 2.0.0 +version: 2.1.0 environment: sdk: '>=3.1.0 <4.0.0'