mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-19 13:23:45 +02:00
feat: customAppbarBuilder
This commit is contained in:
parent
3242002182
commit
154e7a80d1
3 changed files with 15 additions and 4 deletions
|
@ -11,6 +11,7 @@ class AuthScreen extends StatefulWidget {
|
|||
required this.nextBtnTitle,
|
||||
required this.previousBtnTitle,
|
||||
required this.onFinish,
|
||||
this.customAppBar,
|
||||
super.key,
|
||||
}) : assert(steps.length > 0, 'At least one step is required');
|
||||
|
||||
|
@ -23,6 +24,7 @@ class AuthScreen extends StatefulWidget {
|
|||
final String submitBtnTitle;
|
||||
final String nextBtnTitle;
|
||||
final String previousBtnTitle;
|
||||
final AppBar? customAppBar;
|
||||
|
||||
@override
|
||||
State<AuthScreen> createState() => _AuthScreenState();
|
||||
|
@ -34,12 +36,16 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||
final _animationDuration = const Duration(milliseconds: 300);
|
||||
final _animationCurve = Curves.ease;
|
||||
|
||||
AppBar get _appBar =>
|
||||
widget.customAppBar ??
|
||||
AppBar(
|
||||
title: Text(widget.title),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
backgroundColor: Theme.of(context).backgroundColor,
|
||||
appBar: AppBar(
|
||||
title: Text(widget.title),
|
||||
),
|
||||
appBar: _appBar,
|
||||
body: Form(
|
||||
key: _formKey,
|
||||
child: PageView(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_registration/flutter_registration.dart';
|
||||
|
||||
class RegistrationOptions {
|
||||
|
@ -7,12 +7,14 @@ class RegistrationOptions {
|
|||
required this.registrationSteps,
|
||||
required this.afterRegistration,
|
||||
this.registrationTranslations = const RegistrationTranslations(),
|
||||
this.customAppbarBuilder,
|
||||
});
|
||||
|
||||
final RegistrationTranslations registrationTranslations;
|
||||
final List<AuthStep> registrationSteps;
|
||||
final VoidCallback afterRegistration;
|
||||
final RegistrationRepository registrationRepository;
|
||||
final AppBar Function(String title)? customAppbarBuilder;
|
||||
|
||||
static List<AuthStep> get defaultSteps => [
|
||||
AuthStep(
|
||||
|
|
|
@ -32,6 +32,9 @@ class RegistrationScreen extends StatelessWidget {
|
|||
|
||||
return AuthScreen(
|
||||
steps: registrationOptions.registrationSteps,
|
||||
customAppBar: registrationOptions.customAppbarBuilder?.call(
|
||||
translations.title,
|
||||
),
|
||||
onFinish: register,
|
||||
title: translations.title,
|
||||
submitBtnTitle: translations.registerBtn,
|
||||
|
|
Loading…
Reference in a new issue