mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-19 05:23:43 +02:00
Merge pull request #18 from CodeThomnics/bugfix/button_alignment
bugfix: Fix flex overflow, add own padding and alignment option for b…
This commit is contained in:
commit
dcea299aa6
3 changed files with 86 additions and 94 deletions
|
@ -16,6 +16,7 @@ class AuthScreen extends StatefulWidget {
|
||||||
required this.previousBtnTitle,
|
required this.previousBtnTitle,
|
||||||
required this.onFinish,
|
required this.onFinish,
|
||||||
this.customAppBar,
|
this.customAppBar,
|
||||||
|
this.buttonMainAxisAlignment,
|
||||||
this.customBackgroundColor,
|
this.customBackgroundColor,
|
||||||
this.nextButtonBuilder,
|
this.nextButtonBuilder,
|
||||||
this.previousButtonBuilder,
|
this.previousButtonBuilder,
|
||||||
|
@ -38,6 +39,7 @@ class AuthScreen extends StatefulWidget {
|
||||||
final String nextBtnTitle;
|
final String nextBtnTitle;
|
||||||
final String previousBtnTitle;
|
final String previousBtnTitle;
|
||||||
final AppBar? customAppBar;
|
final AppBar? customAppBar;
|
||||||
|
final MainAxisAlignment? buttonMainAxisAlignment;
|
||||||
final Color? customBackgroundColor;
|
final Color? customBackgroundColor;
|
||||||
final Widget Function(Future<void> Function()? onPressed, String label,
|
final Widget Function(Future<void> Function()? onPressed, String label,
|
||||||
int step, bool enabled)? nextButtonBuilder;
|
int step, bool enabled)? nextButtonBuilder;
|
||||||
|
@ -170,7 +172,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
Expanded(
|
Flexible(
|
||||||
flex: widget.formFlex ?? 3,
|
flex: widget.formFlex ?? 3,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
@ -191,103 +193,90 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Column(
|
||||||
padding: EdgeInsets.only(
|
children: [
|
||||||
top: 15.0,
|
Row(
|
||||||
bottom: 30.0,
|
mainAxisAlignment:
|
||||||
left: widget.previousButtonBuilder == null &&
|
widget.buttonMainAxisAlignment != null
|
||||||
widget.steps.first != widget.steps[i]
|
? widget.buttonMainAxisAlignment!
|
||||||
? 30.0
|
: (widget.previousButtonBuilder != null &&
|
||||||
: 0.0,
|
widget.previousButtonBuilder?.call(
|
||||||
right: widget.nextButtonBuilder == null &&
|
onPrevious,
|
||||||
widget.previousButtonBuilder == null
|
widget.previousBtnTitle,
|
||||||
? 30.0
|
i,
|
||||||
: 0.0,
|
) ==
|
||||||
),
|
null)
|
||||||
child: Column(
|
? MainAxisAlignment.start
|
||||||
children: [
|
: widget.steps.first != widget.steps[i]
|
||||||
Row(
|
? MainAxisAlignment.center
|
||||||
mainAxisAlignment:
|
: MainAxisAlignment.end,
|
||||||
(widget.previousButtonBuilder != null &&
|
children: [
|
||||||
widget.previousButtonBuilder?.call(
|
if (widget.previousButtonBuilder == null) ...[
|
||||||
onPrevious,
|
if (widget.steps.first != widget.steps[i])
|
||||||
widget.previousBtnTitle,
|
ElevatedButton(
|
||||||
i,
|
onPressed: onPrevious,
|
||||||
) ==
|
child: Row(
|
||||||
null)
|
children: [
|
||||||
? MainAxisAlignment.spaceAround
|
const Icon(
|
||||||
: widget.steps.first != widget.steps[i]
|
Icons.arrow_back,
|
||||||
? MainAxisAlignment.spaceBetween
|
size: 18,
|
||||||
: MainAxisAlignment.end,
|
),
|
||||||
children: [
|
Padding(
|
||||||
if (widget.previousButtonBuilder == null) ...[
|
padding: const EdgeInsets.only(left: 4.0),
|
||||||
if (widget.steps.first != widget.steps[i])
|
child: Text(widget.previousBtnTitle),
|
||||||
ElevatedButton(
|
),
|
||||||
onPressed: onPrevious,
|
],
|
||||||
child: Row(
|
),
|
||||||
children: [
|
),
|
||||||
const Icon(
|
] else if (widget.previousButtonBuilder?.call(
|
||||||
Icons.arrow_back,
|
onPrevious, widget.previousBtnTitle, i) !=
|
||||||
|
null) ...[
|
||||||
|
widget.previousButtonBuilder!
|
||||||
|
.call(onPrevious, widget.previousBtnTitle, i)!
|
||||||
|
],
|
||||||
|
widget.nextButtonBuilder?.call(
|
||||||
|
!_formValid
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
await onNext(widget.steps[i]);
|
||||||
|
},
|
||||||
|
widget.steps.last == widget.steps[i]
|
||||||
|
? widget.submitBtnTitle
|
||||||
|
: widget.nextBtnTitle,
|
||||||
|
i,
|
||||||
|
_formValid,
|
||||||
|
) ??
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: !_formValid
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
await onNext(widget.steps[i]);
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.steps.last == widget.steps[i]
|
||||||
|
? widget.submitBtnTitle
|
||||||
|
: widget.nextBtnTitle,
|
||||||
|
),
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.only(left: 4.0),
|
||||||
|
child: Icon(
|
||||||
|
Icons.arrow_forward,
|
||||||
size: 18,
|
size: 18,
|
||||||
),
|
),
|
||||||
Padding(
|
),
|
||||||
padding:
|
],
|
||||||
const EdgeInsets.only(left: 4.0),
|
|
||||||
child: Text(widget.previousBtnTitle),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
] else if (widget.previousButtonBuilder?.call(
|
),
|
||||||
onPrevious, widget.previousBtnTitle, i) !=
|
],
|
||||||
null) ...[
|
),
|
||||||
widget.previousButtonBuilder!
|
if (widget.loginButton != null)
|
||||||
.call(onPrevious, widget.previousBtnTitle, i)!
|
Padding(
|
||||||
],
|
padding: const EdgeInsets.only(top: 20.0),
|
||||||
widget.nextButtonBuilder?.call(
|
child: widget.loginButton!,
|
||||||
!_formValid
|
|
||||||
? null
|
|
||||||
: () async {
|
|
||||||
await onNext(widget.steps[i]);
|
|
||||||
},
|
|
||||||
widget.steps.last == widget.steps[i]
|
|
||||||
? widget.submitBtnTitle
|
|
||||||
: widget.nextBtnTitle,
|
|
||||||
i,
|
|
||||||
_formValid,
|
|
||||||
) ??
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: !_formValid
|
|
||||||
? null
|
|
||||||
: () async {
|
|
||||||
await onNext(widget.steps[i]);
|
|
||||||
},
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
widget.steps.last == widget.steps[i]
|
|
||||||
? widget.submitBtnTitle
|
|
||||||
: widget.nextBtnTitle,
|
|
||||||
),
|
|
||||||
const Padding(
|
|
||||||
padding: EdgeInsets.only(left: 4.0),
|
|
||||||
child: Icon(
|
|
||||||
Icons.arrow_forward,
|
|
||||||
size: 18,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
if (widget.loginButton != null)
|
],
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 20.0),
|
|
||||||
child: widget.loginButton!,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -17,6 +17,7 @@ class RegistrationOptions {
|
||||||
this.customAppbarBuilder,
|
this.customAppbarBuilder,
|
||||||
this.nextButtonBuilder,
|
this.nextButtonBuilder,
|
||||||
this.previousButtonBuilder,
|
this.previousButtonBuilder,
|
||||||
|
this.buttonMainAxisAlignment,
|
||||||
this.backgroundColor,
|
this.backgroundColor,
|
||||||
this.titleWidget,
|
this.titleWidget,
|
||||||
this.loginButton,
|
this.loginButton,
|
||||||
|
@ -32,6 +33,7 @@ class RegistrationOptions {
|
||||||
int step, bool enabled)? nextButtonBuilder;
|
int step, bool enabled)? nextButtonBuilder;
|
||||||
final Widget? Function(VoidCallback onPressed, String label, int step)?
|
final Widget? Function(VoidCallback onPressed, String label, int step)?
|
||||||
previousButtonBuilder;
|
previousButtonBuilder;
|
||||||
|
final MainAxisAlignment? buttonMainAxisAlignment;
|
||||||
final Color? backgroundColor;
|
final Color? backgroundColor;
|
||||||
Widget? titleWidget;
|
Widget? titleWidget;
|
||||||
Widget? loginButton;
|
Widget? loginButton;
|
||||||
|
|
|
@ -52,6 +52,7 @@ class RegistrationScreen extends StatelessWidget {
|
||||||
previousBtnTitle: translations.previousStepBtn,
|
previousBtnTitle: translations.previousStepBtn,
|
||||||
nextButtonBuilder: registrationOptions.nextButtonBuilder,
|
nextButtonBuilder: registrationOptions.nextButtonBuilder,
|
||||||
previousButtonBuilder: registrationOptions.previousButtonBuilder,
|
previousButtonBuilder: registrationOptions.previousButtonBuilder,
|
||||||
|
buttonMainAxisAlignment: registrationOptions.buttonMainAxisAlignment,
|
||||||
customBackgroundColor: registrationOptions.backgroundColor,
|
customBackgroundColor: registrationOptions.backgroundColor,
|
||||||
titleWidget: registrationOptions.titleWidget,
|
titleWidget: registrationOptions.titleWidget,
|
||||||
loginButton: registrationOptions.loginButton,
|
loginButton: registrationOptions.loginButton,
|
||||||
|
|
Loading…
Reference in a new issue