You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
diplomatic-quarter/lib/pages/pharmacies/screens/lacum-setting-page.dart

239 lines
8.7 KiB
Dart

import 'package:diplomaticquarterapp/core/model/pharmacies/LacumAccountInformation.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/lacum-viewmodel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/lacum-banner-widget.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
class LakumSettingPage extends StatefulWidget {
final LacumAccountInformation lacumInformation;
final LacumAccountInformation lacumGroupInformation;
LakumSettingPage(this.lacumInformation, this.lacumGroupInformation);
@override
_LakumSettingPageState createState() => _LakumSettingPageState();
}
class _LakumSettingPageState extends State<LakumSettingPage> {
bool _lakumAccountActivated = false;
TextEditingController _nameController = new TextEditingController();
TextEditingController _phoneController = new TextEditingController();
@override
void initState() {
_lakumAccountActivated = widget.lacumGroupInformation
.lakumInquiryInformationObjVersion.accountStatus ==
"Active";
super.initState();
_nameController.text = widget.lacumGroupInformation.lakumInquiryInformationObjVersion.memberName;
_phoneController.text = widget.lacumGroupInformation.lakumInquiryInformationObjVersion.mobileNumber;
}
@override
Widget build(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
return BaseView<LacumViewModel>(
onModelReady: (model) => model.setLakumData(
widget.lacumInformation, widget.lacumGroupInformation),
builder: (_, model, wi) => AppScaffold(
appBarTitle: "${TranslationBase.of(context).lakum}",
isShowAppBar: true,
isShowDecPage: false,
backgroundColor: Colors.white,
baseViewModel: model,
body: Container(
width: double.infinity,
child: SingleChildScrollView(
child: SizedBox(
height: mediaQuery.size.height -
60 -
mediaQuery.padding.top,
child: _buildSettingScreen(mediaQuery, model),
),
),
),
),
);
}
_buildSettingScreen(MediaQueryData mediaQuery, LacumViewModel model) {
bool canUpdate = (_nameController.text != "" &&
_phoneController.text != "" &&
(_nameController.text != widget.lacumGroupInformation.lakumInquiryInformationObjVersion.memberName ||
_phoneController.text != widget.lacumGroupInformation.lakumInquiryInformationObjVersion.mobileNumber));
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [
Container(
height: mediaQuery.size.height * 0.15,
color: Colors.green,
),
Column(
children: [
SizedBox(
height: mediaQuery.size.height * 0.05,
),
Container(
width: mediaQuery.size.width * 1,
child: LakumBannerWidget(model, mediaQuery, false)),
],
)
],
),
SizedBox(
height: 20,
),
SizedBox(
height: 1,
width: double.infinity,
child: Container(
color: Color(0xffefefef),
),
),
Container(
margin: EdgeInsets.symmetric(horizontal: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(
"Activate LAKUM Account",
fontSize: 16,
fontWeight: FontWeight.normal,
color: Colors.black,
),
Switch.adaptive(
activeColor: Color.fromRGBO(51, 153, 51, 1),
inactiveThumbColor: Colors.red,
activeTrackColor: Colors.grey,
inactiveTrackColor: Colors.grey,
value: _lakumAccountActivated,
onChanged: (val) {
if (_lakumAccountActivated) {
model.makeAccountDeactivate();
} else {
model.makeAccountActivate();
}
setState(() {
_lakumAccountActivated = val;
});
},
),
],
),
),
SizedBox(
height: 30,
),
Container(
margin: EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Texts(
TranslationBase.of(context).name,
fontSize: 13,
fontWeight: _lakumAccountActivated
? FontWeight.bold
: FontWeight.normal,
color: Colors.grey.shade400,
),
_lakumAccountActivated
? TextField(
controller: _nameController,
enabled: _lakumAccountActivated ? true : false,
style: TextStyle(
fontSize: 16,
color: _lakumAccountActivated
? Colors.black
: Colors.white38,
),
)
: Texts(
_nameController.text,
fontSize: 16,
color: Colors.grey.shade600,
),
SizedBox(
height: 10,
),
Texts(
TranslationBase.of(context).mobileNumber,
fontSize: 13,
fontWeight: _lakumAccountActivated
? FontWeight.bold
: FontWeight.normal,
color: Colors.grey.shade400,
),
_lakumAccountActivated
? TextField(
controller: _phoneController,
enabled: _lakumAccountActivated ? true : false,
keyboardType: TextInputType.phone,
style: TextStyle(
fontSize: 16,
color: _lakumAccountActivated
? Colors.black
: Colors.white38,
),
)
: Texts(
_phoneController.text,
fontSize: 16,
color: Colors.grey.shade600,
),
],
),
),
],
),
Container(
child: Column(
children: [
SizedBox(
height: 2,
width: double.infinity,
child: Container(
color: Color(0xffefefef),
),
),
Container(
margin: EdgeInsets.all(8),
child: BorderedButton(
TranslationBase.of(context).save,
backgroundColor:
canUpdate ? Color(0xff60686b) : Color(0xffb0b4b5),
textColor: Colors.white,
fontSize: 16,
hPadding: 8,
vPadding: 12,
handler: canUpdate
? () {
model.createLakumAccount(_nameController.text, _phoneController.text).then((status) => {
if (status == 200) {Navigator.pop(context, "")}
// back to previous page
});
}
: null,
),
)
],
),
),
],
);
}
}