200 lines
9.3 KiB
Dart
200 lines
9.3 KiB
Dart
import 'package:aitrainer_app/bloc/account/account_bloc.dart';
|
|
import 'package:aitrainer_app/bloc/customer_change_form_bloc.dart';
|
|
import 'package:aitrainer_app/util/trans.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
|
|
|
import '../library_keys.dart';
|
|
|
|
// ignore: must_be_immutable
|
|
class CustomerModifyPage extends StatelessWidget with Trans {
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
setContext(context);
|
|
// ignore: close_sinks
|
|
final accountBloc = BlocProvider.of<AccountBloc>(context);
|
|
|
|
return BlocProvider(
|
|
create: (context) => CustomerChangeFormBloc(customerRepository: accountBloc.customerRepository),
|
|
child: Builder(builder: (context) {
|
|
// ignore: close_sinks
|
|
final customerBloc = BlocProvider.of<CustomerChangeFormBloc>(context);
|
|
|
|
return Scaffold(
|
|
resizeToAvoidBottomInset: true,
|
|
appBar: AppBar(
|
|
title: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: <Widget>[
|
|
Text("Profil"),
|
|
Image.asset(
|
|
'asset/image/WT_long_logo.png',
|
|
fit: BoxFit.cover,
|
|
height: 65.0,
|
|
),
|
|
],
|
|
),
|
|
//title: Text(AppLocalizations.of(context).translate('Settings')),
|
|
backgroundColor: Colors.transparent,
|
|
),
|
|
body: Container(
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('asset/image/WT_light_background.png'),
|
|
fit: BoxFit.cover,
|
|
alignment: Alignment.center,
|
|
),
|
|
),
|
|
child: Form(
|
|
key: _formKey,
|
|
child: SingleChildScrollView(
|
|
scrollDirection: Axis.vertical,
|
|
padding: EdgeInsets.only(top: 40, left: 25, right: 45, bottom: 100),
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: TextFieldBlocBuilder(
|
|
key: LibraryKeys.loginEmailField,
|
|
style: TextStyle(fontSize: 12),
|
|
textFieldBloc: customerBloc.emailField,
|
|
decoration: InputDecoration(
|
|
fillColor: Colors.white24,
|
|
filled: true,
|
|
labelText: t('Email'),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: TextFieldBlocBuilder(
|
|
style: TextStyle(fontSize: 12),
|
|
textFieldBloc: customerBloc.passwordField,
|
|
suffixButton: SuffixButton.obscureText,
|
|
decoration: InputDecoration(
|
|
fillColor: Colors.white24,
|
|
filled: true,
|
|
labelText: t('Password (Leave empty if no change)'),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: TextFieldBlocBuilder(
|
|
style: TextStyle(fontSize: 12),
|
|
textFieldBloc: customerBloc.nameField,
|
|
decoration: InputDecoration(
|
|
fillColor: Colors.white24,
|
|
filled: true,
|
|
labelText: t('Name'),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: TextFieldBlocBuilder(
|
|
style: TextStyle(fontSize: 12),
|
|
textFieldBloc: customerBloc.firstNameField,
|
|
decoration: InputDecoration(
|
|
fillColor: Colors.white24,
|
|
filled: true,
|
|
labelText: t('First Name'),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: TextFieldBlocBuilder(
|
|
style: TextStyle(fontSize: 12),
|
|
textFieldBloc: customerBloc.birthYearField,
|
|
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d]"))],
|
|
decoration: InputDecoration(
|
|
fillColor: Colors.white24,
|
|
filled: true,
|
|
labelText: t('Birth Year'),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: TextFieldBlocBuilder(
|
|
style: TextStyle(fontSize: 12),
|
|
textFieldBloc: customerBloc.weightField,
|
|
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d]"))],
|
|
decoration: InputDecoration(
|
|
fillColor: Colors.white24,
|
|
filled: true,
|
|
labelText: t('Weight'),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Divider(),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: DropdownFieldBlocBuilder(
|
|
selectFieldBloc: customerBloc.genderField,
|
|
itemBuilder: (context, item) => item,
|
|
decoration: InputDecoration(
|
|
labelText: t('Select a gender'),
|
|
)),
|
|
)
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
Expanded(
|
|
child: RaisedButton(
|
|
color: Colors.orange,
|
|
textColor: Colors.white,
|
|
child: InkWell(child: Text(t("Next"))),
|
|
onPressed: () => {
|
|
customerBloc.add(SubmitFormBloc()),
|
|
Navigator.of(context)
|
|
.pushNamed("customerGoalPage", arguments: customerBloc.customerRepository)
|
|
},
|
|
))
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
)));
|
|
}));
|
|
}
|
|
}
|