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
* Initial release of working flutter_introduction mono project.

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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

View file

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

View file

@ -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<IntroductionPage>? 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;
}

View file

@ -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,
),
),
],
],

View file

@ -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

View file

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