feat: add option for styling introductionbutton texts

This commit is contained in:
Freek van de Ven 2024-01-30 16:51:58 +01:00
parent d4037160ce
commit 0ef937ad8b
13 changed files with 147 additions and 62 deletions

View file

@ -1,3 +1,8 @@
## 2.1.0
* Upgrade dependencies
* Add introductionButtonTextstyles option to IntroductionOptions for styling the introduction button text
## 2.0.0 ## 2.0.0
* Initial release of working flutter_introduction mono project. * Initial release of working flutter_introduction mono project.

View file

@ -19,6 +19,9 @@ scripts:
upgrade: upgrade:
run: melos exec -c 1 -- "flutter pub upgrade" run: melos exec -c 1 -- "flutter pub upgrade"
upgrade-major:
run: melos exec -c 1 -- "flutter pub upgrade --major-versions"
create: create:
# run create in the example folder of flutter_introduction, flutter_introduction_firebase # run create in the example folder of flutter_introduction, flutter_introduction_firebase

View file

@ -17,15 +17,11 @@ dependencies:
flutter_introduction: flutter_introduction:
path: ../ path: ../
flutter_introduction_shared_preferences: flutter_introduction_shared_preferences:
git: path: ../../flutter_introduction_shared_preferences
url: https://github.com/Iconica-Development/flutter_introduction
ref: 2.0.0
path: packages/flutter_introduction_shared_preferences
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.0
flutter_iconica_analysis: flutter_iconica_analysis:
git: git:
url: https://github.com/Iconica-Development/flutter_iconica_analysis url: https://github.com/Iconica-Development/flutter_iconica_analysis

View file

@ -1,6 +1,6 @@
name: flutter_introduction name: flutter_introduction
description: Combined Package of Flutter Introduction Widget and Flutter Introduction Service description: Combined Package of Flutter Introduction Widget and Flutter Introduction Service
version: 2.0.0 version: 2.1.0
publish_to: none publish_to: none
environment: environment:
@ -13,18 +13,17 @@ dependencies:
flutter_introduction_widget: flutter_introduction_widget:
git: git:
url: https://github.com/Iconica-Development/flutter_introduction url: https://github.com/Iconica-Development/flutter_introduction
ref: 2.0.0 ref: 2.1.0
path: packages/flutter_introduction_widget path: packages/flutter_introduction_widget
flutter_introduction_service: flutter_introduction_service:
git: git:
url: https://github.com/Iconica-Development/flutter_introduction url: https://github.com/Iconica-Development/flutter_introduction
ref: 2.0.0 ref: 2.1.0
path: packages/flutter_introduction_service path: packages/flutter_introduction_service
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.0
flutter_iconica_analysis: flutter_iconica_analysis:
git: git:
url: https://github.com/Iconica-Development/flutter_iconica_analysis url: https://github.com/Iconica-Development/flutter_iconica_analysis

View file

@ -1,6 +1,6 @@
name: flutter_introduction_firebase name: flutter_introduction_firebase
description: Flutter Introduction Page that uses firebase for the pages and some settings description: Flutter Introduction Page that uses firebase for the pages and some settings
version: 2.0.0 version: 2.1.0
publish_to: none publish_to: none
environment: environment:
@ -15,12 +15,12 @@ dependencies:
flutter_introduction_widget: flutter_introduction_widget:
git: git:
url: https://github.com/Iconica-Development/flutter_introduction url: https://github.com/Iconica-Development/flutter_introduction
ref: 2.0.0 ref: 2.1.0
path: packages/flutter_introduction_widget path: packages/flutter_introduction_widget
flutter_introduction_service: flutter_introduction_service:
git: git:
url: https://github.com/Iconica-Development/flutter_introduction url: https://github.com/Iconica-Development/flutter_introduction
ref: 2.0.0 ref: 2.1.0
path: packages/flutter_introduction_service path: packages/flutter_introduction_service
dev_dependencies: dev_dependencies:

View file

@ -1,6 +1,6 @@
name: flutter_introduction_interface name: flutter_introduction_interface
description: A new Flutter package project. description: A new Flutter package project.
version: 2.0.0 version: 2.1.0
publish_to: none publish_to: none
environment: environment:
@ -18,7 +18,6 @@ dependencies:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.0
flutter_iconica_analysis: flutter_iconica_analysis:
git: git:
url: https://github.com/Iconica-Development/flutter_iconica_analysis url: https://github.com/Iconica-Development/flutter_iconica_analysis

View file

@ -1,6 +1,6 @@
name: flutter_introduction_service name: flutter_introduction_service
description: A new Flutter package project. description: A new Flutter package project.
version: 2.0.0 version: 2.1.0
publish_to: none publish_to: none
environment: environment:
@ -13,13 +13,12 @@ dependencies:
flutter_introduction_interface: flutter_introduction_interface:
git: git:
url: https://github.com/Iconica-Development/flutter_introduction url: https://github.com/Iconica-Development/flutter_introduction
ref: 2.0.0 ref: 2.1.0
path: packages/flutter_introduction_interface path: packages/flutter_introduction_interface
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.0
flutter_iconica_analysis: flutter_iconica_analysis:
git: git:
url: https://github.com/Iconica-Development/flutter_iconica_analysis url: https://github.com/Iconica-Development/flutter_iconica_analysis

View file

@ -1,6 +1,6 @@
name: flutter_introduction_shared_preferences name: flutter_introduction_shared_preferences
description: A new Flutter package project. description: A new Flutter package project.
version: 2.0.0 version: 2.1.0
publish_to: none publish_to: none
environment: environment:
@ -13,14 +13,13 @@ dependencies:
flutter_introduction_interface: flutter_introduction_interface:
git: git:
url: https://github.com/Iconica-Development/flutter_introduction url: https://github.com/Iconica-Development/flutter_introduction
ref: 2.0.0 ref: 2.1.0
path: packages/flutter_introduction_interface path: packages/flutter_introduction_interface
shared_preferences: any shared_preferences: any
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.0
flutter_iconica_analysis: flutter_iconica_analysis:
git: git:
url: https://github.com/Iconica-Development/flutter_iconica_analysis url: https://github.com/Iconica-Development/flutter_iconica_analysis

View file

@ -18,7 +18,7 @@ dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.0 flutter_lints: ^3.0.1
flutter: flutter:

View file

@ -59,6 +59,7 @@ class IntroductionPage {
class IntroductionOptions { class IntroductionOptions {
const IntroductionOptions({ const IntroductionOptions({
this.introductionTranslations = const IntroductionTranslations(), this.introductionTranslations = const IntroductionTranslations(),
this.introductionButtonTextstyles = const IntroductionButtonTextstyles(),
this.indicatorMode = IndicatorMode.dash, this.indicatorMode = IndicatorMode.dash,
this.indicatorBuilder, this.indicatorBuilder,
this.layoutStyle = IntroductionLayoutStyle.imageCenter, this.layoutStyle = IntroductionLayoutStyle.imageCenter,
@ -79,12 +80,12 @@ class IntroductionOptions {
); );
/// Determine when the introduction screens needs to be shown. /// Determine when the introduction screens needs to be shown.
/// ///
/// [IntroductionScreenMode.showNever] To disable introduction screens. /// [IntroductionScreenMode.showNever] To disable introduction screens.
/// ///
/// [IntroductionScreenMode.showAlways] To always show the introduction /// [IntroductionScreenMode.showAlways] To always show the introduction
/// screens on startup. /// screens on startup.
/// ///
/// [IntroductionScreenMode.showOnce] To only show the introduction screens /// [IntroductionScreenMode.showOnce] To only show the introduction screens
/// once on startup. /// once on startup.
final IntroductionScreenMode mode; final IntroductionScreenMode mode;
@ -101,13 +102,13 @@ class IntroductionOptions {
/// introduction screen. /// introduction screen.
/// Introduction screens can always be navigated by swiping (or tapping if /// Introduction screens can always be navigated by swiping (or tapping if
/// [tapEnabled] is enabled). /// [tapEnabled] is enabled).
/// ///
/// [IntroductionScreenButtonMode.text] Use text buttons (text can be set by /// [IntroductionScreenButtonMode.text] Use text buttons (text can be set by
/// setting the translation key or using the default appshell translations). /// setting the translation key or using the default appshell translations).
/// ///
/// [IntroductionScreenButtonMode.icon] Use icon buttons (icons can be /// [IntroductionScreenButtonMode.icon] Use icon buttons (icons can be
/// changed by providing a icon library) /// changed by providing a icon library)
/// ///
/// [IntroductionScreenButtonMode.disabled] Disable buttons. /// [IntroductionScreenButtonMode.disabled] Disable buttons.
final IntroductionScreenButtonMode buttonMode; final IntroductionScreenButtonMode buttonMode;
@ -115,21 +116,21 @@ class IntroductionOptions {
/// using [pages]. /// using [pages].
/// Every introduction page provided with a image or icon will use the same /// Every introduction page provided with a image or icon will use the same
/// layout setting. /// layout setting.
/// ///
/// [IntroductionLayoutStyle.imageCenter] Image/icon will be at the center of the introduction page. /// [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.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. /// [IntroductionLayoutStyle.imageBottom] Image/icon will be at the bottom of the introduction page.
final IntroductionLayoutStyle layoutStyle; final IntroductionLayoutStyle layoutStyle;
/// Determines the style of the page indicator shown at the bottom on the /// Determines the style of the page indicator shown at the bottom on the
/// introduction pages. /// introduction pages.
/// ///
/// [IndicatorMode.dot] Shows a dot for each page. /// [IndicatorMode.dot] Shows a dot for each page.
/// ///
/// [IndicatorMode.dash] Shows a dash for each page. /// [IndicatorMode.dash] Shows a dash for each page.
/// ///
/// [IndicatorMode.custom] calls indicatorBuilder for the indicator /// [IndicatorMode.custom] calls indicatorBuilder for the indicator
final IndicatorMode indicatorMode; final IndicatorMode indicatorMode;
@ -152,23 +153,23 @@ class IntroductionOptions {
/// [IntroductionDisplayMode.multiPageHorizontal] Configured introduction /// [IntroductionDisplayMode.multiPageHorizontal] Configured introduction
/// pages will be shown on seperate screens and can be navigated using using /// pages will be shown on seperate screens and can be navigated using using
/// buttons (if enabled) or swiping. /// buttons (if enabled) or swiping.
/// ///
/// !Unimplemented! [IntroductionDisplayMode.singleScrollablePageVertical] /// !Unimplemented! [IntroductionDisplayMode.singleScrollablePageVertical]
/// All configured introduction pages will be shown on a single scrollable /// All configured introduction pages will be shown on a single scrollable
/// page. /// page.
/// ///
final IntroductionDisplayMode displayMode; final IntroductionDisplayMode displayMode;
/// When [IntroductionDisplayMode.multiPageHorizontal] is selected multiple /// When [IntroductionDisplayMode.multiPageHorizontal] is selected multiple
/// controlMode can be selected. /// controlMode can be selected.
/// ///
/// [IntroductionControlMode.previousNextButton] shows two buttons at the /// [IntroductionControlMode.previousNextButton] shows two buttons at the
/// bottom of the screen to return or proceed. The skip button is placed at /// bottom of the screen to return or proceed. The skip button is placed at
/// the top left of the screen. /// the top left of the screen.
/// ///
/// [IntroductionControlMode.singleButton] contains one button at the bottom /// [IntroductionControlMode.singleButton] contains one button at the bottom
/// of the screen to proceed. Underneath is clickable text to skip if the /// 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 /// current page is the first page. If the current page is any different it
/// return to the previous screen. /// return to the previous screen.
/// ///
final IntroductionControlMode controlMode; final IntroductionControlMode controlMode;
@ -192,6 +193,16 @@ class IntroductionOptions {
/// - Finish /// - Finish
final IntroductionTranslations introductionTranslations; 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({ IntroductionOptions copyWith({
IntroductionScreenMode? mode, IntroductionScreenMode? mode,
List<IntroductionPage>? pages, List<IntroductionPage>? pages,
@ -212,6 +223,7 @@ class IntroductionOptions {
Widget Function(BuildContext, VoidCallback, Widget, IntroductionButtonType)? Widget Function(BuildContext, VoidCallback, Widget, IntroductionButtonType)?
buttonBuilder, buttonBuilder,
IntroductionTranslations? introductionTranslations, IntroductionTranslations? introductionTranslations,
IntroductionButtonTextstyles? introductionButtonTextstyles,
}) => }) =>
IntroductionOptions( IntroductionOptions(
mode: mode ?? this.mode, mode: mode ?? this.mode,
@ -228,10 +240,11 @@ class IntroductionOptions {
buttonBuilder: buttonBuilder ?? this.buttonBuilder, buttonBuilder: buttonBuilder ?? this.buttonBuilder,
introductionTranslations: introductionTranslations:
introductionTranslations ?? this.introductionTranslations, introductionTranslations ?? this.introductionTranslations,
introductionButtonTextstyles:
introductionButtonTextstyles ?? this.introductionButtonTextstyles,
); );
} }
///
class IntroductionTranslations { class IntroductionTranslations {
const IntroductionTranslations({ const IntroductionTranslations({
this.skipButton = 'skip', this.skipButton = 'skip',
@ -244,3 +257,16 @@ class IntroductionTranslations {
final String previousButton; final String previousButton;
final String finishButton; 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;
}

View file

@ -326,12 +326,20 @@ class IntroductionTwoButtons extends StatelessWidget {
options.buttonBuilder?.call( options.buttonBuilder?.call(
context, context,
_previous, _previous,
Text(translations.previousButton), Text(
translations.previousButton,
style: options
.introductionButtonTextstyles.previousButtonStyle,
),
IntroductionButtonType.previous, IntroductionButtonType.previous,
) ?? ) ??
TextButton( TextButton(
onPressed: _previous, onPressed: _previous,
child: Text(translations.previousButton), child: Text(
translations.previousButton,
style: options
.introductionButtonTextstyles.previousButtonStyle,
),
), ),
] else ] else
const SizedBox.shrink(), const SizedBox.shrink(),
@ -339,12 +347,18 @@ class IntroductionTwoButtons extends StatelessWidget {
options.buttonBuilder?.call( options.buttonBuilder?.call(
context, context,
_next, _next,
Text(translations.nextButton), Text(
translations.nextButton,
style: options.introductionButtonTextstyles.nextButtonStyle,
),
IntroductionButtonType.next, IntroductionButtonType.next,
) ?? ) ??
TextButton( TextButton(
onPressed: _next, onPressed: _next,
child: Text(translations.nextButton), child: Text(
translations.nextButton,
style: options.introductionButtonTextstyles.nextButtonStyle,
),
), ),
] else if (last) ...[ ] else if (last) ...[
options.buttonBuilder?.call( options.buttonBuilder?.call(
@ -352,14 +366,22 @@ class IntroductionTwoButtons extends StatelessWidget {
() { () {
onFinish?.call(); onFinish?.call();
}, },
Text(translations.finishButton), Text(
translations.finishButton,
style:
options.introductionButtonTextstyles.finishButtonStyle,
),
IntroductionButtonType.finish, IntroductionButtonType.finish,
) ?? ) ??
TextButton( TextButton(
onPressed: () { onPressed: () {
onFinish?.call(); onFinish?.call();
}, },
child: Text(translations.finishButton), child: Text(
translations.finishButton,
style:
options.introductionButtonTextstyles.finishButtonStyle,
),
), ),
] else ...[ ] else ...[
const SizedBox.shrink(), const SizedBox.shrink(),
@ -379,14 +401,22 @@ class IntroductionTwoButtons extends StatelessWidget {
() { () {
onFinish?.call(); onFinish?.call();
}, },
Text(translations.finishButton), Text(
translations.finishButton,
style: options
.introductionButtonTextstyles.finishButtonStyle,
),
IntroductionButtonType.finish, IntroductionButtonType.finish,
) ?? ) ??
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
onFinish?.call(); onFinish?.call();
}, },
child: Text(translations.finishButton), child: Text(
translations.finishButton,
style: options
.introductionButtonTextstyles.finishButtonStyle,
),
), ),
), ),
), ),
@ -450,37 +480,59 @@ class IntroductionOneButton extends StatelessWidget {
() { () {
onFinish?.call(); onFinish?.call();
}, },
Text(translations.finishButton), Text(
translations.finishButton,
style:
options.introductionButtonTextstyles.finishButtonStyle,
),
IntroductionButtonType.finish, IntroductionButtonType.finish,
) ?? ) ??
TextButton( TextButton(
onPressed: () { onPressed: () {
onFinish?.call(); onFinish?.call();
}, },
child: Text(translations.finishButton), child: Text(
translations.finishButton,
style:
options.introductionButtonTextstyles.finishButtonStyle,
),
), ),
] else ...[ ] else ...[
options.buttonBuilder?.call( options.buttonBuilder?.call(
context, context,
_next, _next,
Text(translations.nextButton), Text(
translations.nextButton,
style: options.introductionButtonTextstyles.nextButtonStyle,
),
IntroductionButtonType.next, IntroductionButtonType.next,
) ?? ) ??
TextButton( TextButton(
onPressed: _next, onPressed: _next,
child: Text(translations.nextButton), child: Text(
translations.nextButton,
style: options.introductionButtonTextstyles.nextButtonStyle,
),
), ),
], ],
if (previous) ...[ if (previous) ...[
options.buttonBuilder?.call( options.buttonBuilder?.call(
context, context,
_previous, _previous,
Text(translations.previousButton), Text(
translations.previousButton,
style: options
.introductionButtonTextstyles.previousButtonStyle,
),
IntroductionButtonType.previous, IntroductionButtonType.previous,
) ?? ) ??
TextButton( TextButton(
onPressed: _previous, onPressed: _previous,
child: Text(translations.previousButton), child: Text(
translations.previousButton,
style: options
.introductionButtonTextstyles.previousButtonStyle,
),
), ),
] else ...[ ] else ...[
options.buttonBuilder?.call( options.buttonBuilder?.call(
@ -488,14 +540,22 @@ class IntroductionOneButton extends StatelessWidget {
() { () {
onFinish?.call(); onFinish?.call();
}, },
Text(translations.finishButton), Text(
translations.finishButton,
style:
options.introductionButtonTextstyles.finishButtonStyle,
),
IntroductionButtonType.skip, IntroductionButtonType.skip,
) ?? ) ??
TextButton( TextButton(
onPressed: () { onPressed: () {
onFinish?.call(); onFinish?.call();
}, },
child: Text(translations.finishButton), child: Text(
translations.finishButton,
style:
options.introductionButtonTextstyles.finishButtonStyle,
),
), ),
], ],
], ],

View file

@ -1,6 +1,6 @@
name: flutter_introduction_widget name: flutter_introduction_widget
description: Flutter Introduction Widget for showing a list of introduction pages on a single scrollable page or horizontal pageview 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 homepage: https://github.com/Iconica-Development/flutter_introduction_widget
environment: environment:
@ -14,7 +14,6 @@ dependencies:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.0
flutter_iconica_analysis: flutter_iconica_analysis:
git: git:
url: https://github.com/Iconica-Development/flutter_iconica_analysis url: https://github.com/Iconica-Development/flutter_iconica_analysis

View file

@ -1,5 +1,5 @@
name: flutter_introduction_workspace name: flutter_introduction_workspace
version: 2.0.0 version: 2.1.0
environment: environment:
sdk: '>=3.1.0 <4.0.0' sdk: '>=3.1.0 <4.0.0'