2023-04-11 06:08:10 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-04-13 08:45:19 +00:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2023-04-11 06:08:10 +00:00
|
|
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
2023-08-22 06:22:08 +00:00
|
|
|
import 'package:form_builder_validators/form_builder_validators.dart';
|
2023-04-13 08:45:19 +00:00
|
|
|
import 'package:unit2/bloc/sos/sos_bloc.dart';
|
2023-04-11 06:08:10 +00:00
|
|
|
import 'package:unit2/screens/sos/components/request_sos.dart';
|
|
|
|
import 'package:unit2/theme-data.dart/text-styles.dart';
|
|
|
|
import 'package:unit2/utils/screen_info.dart';
|
|
|
|
import '../../../theme-data.dart/btn-style.dart';
|
|
|
|
import '../../../theme-data.dart/colors.dart';
|
|
|
|
import '../../../theme-data.dart/form-style.dart';
|
|
|
|
import '../../../utils/global.dart';
|
|
|
|
import '../../../utils/text_container.dart';
|
|
|
|
import '../../../utils/validators.dart';
|
|
|
|
import '../../../widgets/wave.dart';
|
|
|
|
|
|
|
|
class AddMobile extends StatelessWidget {
|
|
|
|
AddMobile({super.key});
|
|
|
|
final _formKey = GlobalKey<FormBuilderState>();
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-04-13 08:45:19 +00:00
|
|
|
|
|
|
|
return BlocBuilder<SosBloc, SosState>(
|
|
|
|
builder: (context, state) {
|
|
|
|
if(state is UserLocationLoaded){
|
|
|
|
return SingleChildScrollView(
|
2023-04-11 06:08:10 +00:00
|
|
|
child: SizedBox(
|
2023-04-13 08:45:19 +00:00
|
|
|
height: screenHeight * .95,
|
2023-04-11 06:08:10 +00:00
|
|
|
child: Stack(
|
|
|
|
children: [
|
2023-04-13 08:45:19 +00:00
|
|
|
|
2023-04-11 06:08:10 +00:00
|
|
|
Positioned(
|
|
|
|
bottom: 0,
|
|
|
|
right: 0,
|
|
|
|
child: WaveReverse(height: blockSizeVertical * 8)),
|
|
|
|
Container(
|
|
|
|
height: screenHeight,
|
|
|
|
padding: isMobile()
|
2023-06-21 00:22:43 +00:00
|
|
|
? const EdgeInsets.symmetric(horizontal: 60)
|
2023-04-11 06:08:10 +00:00
|
|
|
: const EdgeInsets.symmetric(horizontal: 60),
|
|
|
|
width: double.infinity,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
2023-06-21 00:22:43 +00:00
|
|
|
const SizedBox(height: 100,),
|
2023-04-11 06:08:10 +00:00
|
|
|
SvgPicture.asset(
|
|
|
|
'assets/svgs/add_mobile.svg',
|
|
|
|
height: isMobile()
|
|
|
|
? blockSizeVertical * 22
|
|
|
|
: blockSizeVertical * 30,
|
|
|
|
allowDrawingOutsideViewBox: true,
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 24,
|
|
|
|
),
|
2023-06-21 00:22:43 +00:00
|
|
|
Text(addMobile,textAlign: TextAlign.center, style: titleTextStyle()),
|
2023-04-11 06:08:10 +00:00
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
Text(addMobileCaption,
|
|
|
|
textAlign: TextAlign.center,
|
2023-06-21 00:22:43 +00:00
|
|
|
style: Theme.of(context).textTheme.bodySmall),
|
2023-04-11 06:08:10 +00:00
|
|
|
const SizedBox(
|
|
|
|
height: 24,
|
|
|
|
),
|
|
|
|
FormBuilder(
|
|
|
|
key: _formKey,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
2023-04-13 08:45:19 +00:00
|
|
|
//// Mobile number 1
|
2023-04-11 06:08:10 +00:00
|
|
|
FormBuilderTextField(
|
2023-08-22 06:22:08 +00:00
|
|
|
keyboardType: const TextInputType.numberWithOptions(),
|
2023-04-13 08:45:19 +00:00
|
|
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
2023-04-11 06:08:10 +00:00
|
|
|
name: 'mobile1',
|
|
|
|
validator: mobileNumberValidator,
|
|
|
|
maxLength: 11,
|
|
|
|
decoration:
|
2023-08-22 06:22:08 +00:00
|
|
|
normalTextFieldStyle(mobile1, "+639000000000")),
|
2023-06-21 00:22:43 +00:00
|
|
|
|
2023-04-13 08:45:19 +00:00
|
|
|
//// Mobile number 2
|
2023-04-11 06:08:10 +00:00
|
|
|
FormBuilderTextField(
|
2023-08-22 06:22:08 +00:00
|
|
|
|
|
|
|
keyboardType: const TextInputType.numberWithOptions(),
|
2023-04-13 08:45:19 +00:00
|
|
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
2023-04-11 06:08:10 +00:00
|
|
|
name: 'mobile2',
|
2023-04-13 08:45:19 +00:00
|
|
|
|
2023-04-11 06:08:10 +00:00
|
|
|
decoration:
|
2023-08-22 06:22:08 +00:00
|
|
|
normalTextFieldStyle(mobile2, "+639000000000")),
|
2023-04-13 08:45:19 +00:00
|
|
|
|
2023-06-21 00:22:43 +00:00
|
|
|
const SizedBox(height: 30,),
|
2023-04-11 06:08:10 +00:00
|
|
|
SizedBox(
|
|
|
|
width: double.infinity,
|
|
|
|
height: screenHeight * .06,
|
|
|
|
child: ElevatedButton(
|
2023-04-13 08:45:19 +00:00
|
|
|
style: secondaryBtnStyle(primary,
|
2023-04-11 06:08:10 +00:00
|
|
|
Colors.transparent, Colors.white54),
|
|
|
|
child: const Text(
|
|
|
|
submit,
|
|
|
|
style: TextStyle(color: Colors.white),
|
2023-04-13 08:45:19 +00:00
|
|
|
),//// on pressed
|
2023-04-11 06:08:10 +00:00
|
|
|
onPressed: () {
|
|
|
|
if (_formKey.currentState!
|
|
|
|
.saveAndValidate()) {
|
2023-04-13 08:45:19 +00:00
|
|
|
String mobile1 = _formKey.currentState!.value['mobile1'];
|
|
|
|
String? mobile2 = _formKey.currentState!.value['mobile2'];
|
|
|
|
context.read<SosBloc>().add(SubmitMobile(mobile1: mobile1, mobile2: mobile2));
|
2023-04-11 06:08:10 +00:00
|
|
|
}
|
2023-04-13 08:45:19 +00:00
|
|
|
|
2023-04-11 06:08:10 +00:00
|
|
|
// }
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
))
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2023-04-13 08:45:19 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
|
|
|
|
},
|
2023-04-11 06:08:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|