Changes for Phase-1

merge-requests/1/merge
Sikander Saleem 3 years ago
parent c713184c78
commit 9ce90c745f

@ -96,7 +96,7 @@
"nameExist": "Name Exist", "nameExist": "Name Exist",
"newServiceRequest": "New Service Request", "newServiceRequest": "New Service Request",
"newWord": "New", "newWord": "New",
"noDateFound": "No Date Found", "noDateFound": "No Data Found",
"noDeviceFound": "No Device Found", "noDeviceFound": "No Device Found",
"noHospitalFound": "No Client Found", "noHospitalFound": "No Client Found",
"noModelFound": "No Model Found", "noModelFound": "No Model Found",

@ -0,0 +1,13 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:test_sa/views/app_style/colors.dart';
extension IntExtensions on int {
Widget get height => SizedBox(height: toDouble());
Widget get width => SizedBox(width: toDouble());
Widget get divider => Divider(height: toDouble(), thickness: toDouble(), color: AColors.greyEF);
Widget get makeItSquare => SizedBox(width: toDouble(), height: toDouble());
}

@ -0,0 +1,245 @@
//
// import 'package:flutter/cupertino.dart';
// import 'package:intl/intl.dart';
//
// extension CapExtension on String {
// String get toCamelCase => "${this[0].toUpperCase()}${this.substring(1)}";
//
// String get inCaps => '${this[0].toUpperCase()}${this.substring(1)}';
//
// String get allInCaps => this.toUpperCase();
//
// String get capitalizeFirstofEach => this.trim().length > 0 ? this.trim().toLowerCase().split(" ").map((str) => str.inCaps).join(" ") : "";
// }
//
// extension EmailValidator on String {
// Widget get toWidget => Text(this);
//
// Widget toText10({Color? color, bool isBold = false, int? maxlines, FontStyle? fontStyle}) => Text(
// this,
// maxLines: maxlines,
// style: TextStyle(fontSize: 10, fontStyle: fontStyle ?? FontStyle.normal, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.4),
// );
//
// Widget toText11({Color? color, FontWeight? weight, bool isUnderLine = false, bool isBold = false, int maxLine = 0}) => Text(
// this,
// maxLines: (maxLine > 0) ? maxLine : null,
// style: TextStyle(
// fontSize: 11,
// fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600),
// color: color ?? MyColors.darkTextColor,
// letterSpacing: -0.33,
// decoration: isUnderLine ? TextDecoration.underline : null,
// ),
// );
//
// Widget toText12({Color? color, bool isUnderLine = false, bool isBold = false, bool isCenter = false, int maxLine = 0}) => Text(
// this,
// textAlign: isCenter ? TextAlign.center : null,
// maxLines: (maxLine > 0) ? maxLine : null,
// style: TextStyle(
// fontSize: 12,
// fontWeight: isBold ? FontWeight.bold : FontWeight.w600,
// color: color ?? MyColors.darkTextColor,
// letterSpacing: -0.72,
// decoration: isUnderLine ? TextDecoration.underline : null,
// ),
// );
//
// Widget toText12Auto({Color? color, bool isUnderLine = false, bool isBold = false, bool isCenter = false, int maxLine = 0}) => AutoSizeText(
// this,
// textAlign: isCenter ? TextAlign.center : null,
// maxLines: (maxLine > 0) ? maxLine : null,
// minFontSize: 8,
// style: TextStyle(
// fontSize: 12,
// fontWeight: isBold ? FontWeight.bold : FontWeight.w600,
// color: color ?? MyColors.darkTextColor,
// letterSpacing: -0.72,
// decoration: isUnderLine ? TextDecoration.underline : null,
// ),
// );
//
// Widget toTextAuto({
// Color? color,
// bool isUnderLine = false,
// bool isBold = false,
// bool isCenter = false,
// int maxLine = 0,
// double fontSize = 12,
// double letterSpacing = -0.72,
// double height = 1,
// }) =>
// AutoSizeText(
// this,
// textAlign: isCenter ? TextAlign.center : null,
// maxLines: (maxLine > 0) ? maxLine : null,
// minFontSize: 5,
// style: TextStyle(
// fontSize: fontSize,
// fontWeight: isBold ? FontWeight.bold : FontWeight.w600,
// color: color ?? MyColors.darkTextColor,
// letterSpacing: letterSpacing,
// decoration: isUnderLine ? TextDecoration.underline : null,
// ),
// );
//
// Widget toText13({Color? color, bool isUnderLine = false}) => Text(
// this,
// style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.52, decoration: isUnderLine ? TextDecoration.underline : null),
// );
//
// Widget toText14({Color? color, bool isUnderLine = false, bool isBold = false, FontWeight? weight, int? maxlines, TextAlign? textAlign, bool isCenter = false}) => Text(
// this,
// textAlign: isCenter ? TextAlign.center : (textAlign ?? TextAlign.left),
// maxLines: maxlines,
// style: TextStyle(
// color: color ?? MyColors.darkTextColor,
// fontSize: 14,
// letterSpacing: -0.48,
// fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600),
// decoration: isUnderLine ? TextDecoration.underline : null),
// );
//
// Widget toText16({Color? color, bool isUnderLine = false, bool isBold = false, int? maxlines, double? height}) => Text(
// this,
// maxLines: maxlines,
// style: TextStyle(
// color: color ?? MyColors.darkTextColor,
// fontSize: 16,
// letterSpacing: -0.64,
// height: height,
// fontWeight: isBold ? FontWeight.bold : FontWeight.w600,
// decoration: isUnderLine ? TextDecoration.underline : null,
// ),
// );
//
// Widget toText17({Color? color, bool isBold = false}) => Text(
// this,
// style: TextStyle(color: color ?? MyColors.darkTextColor, fontSize: 17, letterSpacing: -0.68, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
// );
//
// Widget toText18({Color? color, bool isBold = false, bool isCentered = false}) => Text(
// this,
// textAlign: isCentered ? TextAlign.center : null,
// style: TextStyle(fontSize: 18, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -1.08),
// );
//
// Widget toText19({Color? color, bool isBold = false}) => Text(
// this,
// style: TextStyle(fontSize: 19, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -1.14),
// );
//
// Widget toText20({Color? color, bool isBold = false, bool isCentered = false}) => Text(
// this,
// textAlign: isCentered ? TextAlign.center : null,
// style: TextStyle(fontSize: 20, fontWeight: isBold ? FontWeight.bold : FontWeight.w600, color: color ?? MyColors.darkTextColor, letterSpacing: -0.4),
// );
//
// Widget toText21({Color? color, bool isBold = false, FontWeight? weight, int? maxlines}) => Text(
// this,
// maxLines: maxlines,
// style: TextStyle(color: color ?? MyColors.grey3AColor, fontSize: 21, letterSpacing: -0.84, fontWeight: weight ?? (isBold ? FontWeight.bold : FontWeight.w600)),
// );
//
// Widget toText22({Color? color, bool isBold = false, bool isCentered = false}) => Text(
// this,
// textAlign: isCentered ? TextAlign.center : null,
// style: TextStyle(height: 1, color: color ?? MyColors.darkTextColor, fontSize: 22, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
// );
//
// Widget toText24({Color? color, bool isBold = false}) => Text(
// this,
// style: TextStyle(height: 23 / 24, color: color ?? MyColors.darkTextColor, fontSize: 24, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
// );
//
// Widget toText30({Color? color, bool isBold = false}) => Text(
// this,
// style: TextStyle(height: 20 / 32, color: color ?? MyColors.darkTextColor, fontSize: 32, letterSpacing: -1.2, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
// );
//
// Widget toText32({Color? color, bool isBold = false, bool isCentered = false}) => Text(
// this,
// textAlign: isCentered ? TextAlign.center : null,
// style: TextStyle(height: 32 / 32, color: color ?? MyColors.darkTextColor, fontSize: 32, letterSpacing: -1.92, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
// );
//
// Widget toText44({Color? color, bool isBold = false}) => Text(
// this,
// style: TextStyle(height: 32 / 32, color: color ?? MyColors.darkTextColor, fontSize: 44, letterSpacing: -2.64, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
// );
//
// Widget toSectionHeading({String upperHeading = "", String lowerHeading = ""}) {
// String upper = "";
// String lower = "";
// String heading = this;
// if (heading.isNotEmpty) {
// List<String> data = heading.split(" ");
//
// if (data.length > 1) {
// upper = data[0];
// data.removeAt(0);
// lower = data.join(" ");
// } else {
// lower = data[0];
// }
// }
// if (upperHeading.isNotEmpty) {
// upper = upperHeading;
// }
// if (lowerHeading.isNotEmpty) {
// lower = lowerHeading;
// }
//
// return Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
// children: [
// if (upper.isNotEmpty) upper.toText12(),
// lower.toText24(isBold: true),
// ],
// );
// }
//
// bool isValidEmail() {
// return RegExp(r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$').hasMatch(this);
// }
//
// String toFormattedDate() {
// String date = this.split("T")[0];
// String time = this.split("T")[1];
// var dates = date.split("-");
// return "${dates[2]} ${getMonth(int.parse(dates[1]))} ${dates[0]} ${DateFormat('hh:mm a').format(DateFormat('hh:mm:ss').parse(time))}";
// }
//
// String getMonth(int month) {
// switch (month) {
// case 1:
// return "January";
// case 2:
// return "February";
// case 3:
// return "March";
// case 4:
// return "April";
// case 5:
// return "May";
// case 6:
// return "June";
// case 7:
// return "July";
// case 8:
// return "August";
// case 9:
// return "September";
// case 10:
// return "October";
// case 11:
// return "November";
// case 12:
// return "December";
// default:
// return "";
// }
// }
// }

@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:test_sa/views/app_style/colors.dart';
extension WidgetExtensions on Widget {
Widget onPress(VoidCallback onTap) => InkWell(onTap: onTap, child: this);
Widget get expanded => Expanded(child: this);
Widget get center => Center(child: this);
Widget circle(double _value) => ClipRRect(borderRadius: BorderRadius.circular(_value), child: this);
Widget paddingAll(double _value) => Padding(padding: EdgeInsets.all(_value), child: this);
Widget paddingOnly({double left = 0.0, double right = 0.0, double top = 0.0, double bottom = 0.0}) =>
Padding(padding: EdgeInsets.only(left: left, right: right, top: top, bottom: bottom), child: this);
Widget toExpanded({int flex = 1}) => Expanded(flex: flex, child: this);
}

@ -92,7 +92,7 @@ class MyApp extends StatelessWidget {
title: 'ATOMS', title: 'ATOMS',
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
theme: ThemeData( theme: ThemeData(
fontFamily: "Swiss", fontFamily: "Poppins",
//canvasColor: AColors.primaryColor, //canvasColor: AColors.primaryColor,
scaffoldBackgroundColor: AColors.scaffoldBackgroundColor, scaffoldBackgroundColor: AColors.scaffoldBackgroundColor,
primaryColor: AColors.primaryColor, primaryColor: AColors.primaryColor,

@ -4,6 +4,7 @@ class AColors {
AColors._(); AColors._();
static const Color white = Color(0xffffffff); static const Color white = Color(0xffffffff);
static const Color black = Color(0xff000000); static const Color black = Color(0xff000000);
static const Color grey3A = Color(0xff2e303a);
static const Color grey = Color(0xffe1e7e7); static const Color grey = Color(0xffe1e7e7);
static const green = Colors.green; static const green = Colors.green;
static const Color orange = Colors.orange; static const Color orange = Colors.orange;
@ -12,9 +13,11 @@ class AColors {
static const Color deepRed = Color(0xFFD32F2F); static const Color deepRed = Color(0xFFD32F2F);
static const Color scaffoldBackgroundColor = Color(0xffffffff); static const Color scaffoldBackgroundColor = Color(0xffffffff);
static const Color secondaryColor = Color(0xff111427); static const Color secondaryColor = Color(0xff111427);
static const Color primaryColor = Color(0xff3B7097); static const Color primaryColor = Color(0xff5bb0da);
static const Color cyan = Color(0xff4A8DB7); static const Color cyan = Color(0xff4A8DB7);
static const Color onPrimaryColor = Color(0xffffffff); static const Color onPrimaryColor = Color(0xffffffff);
static Color inputFieldBackgroundColor = Color(0xfff5f5f5);
static Color greyEF = Color(0xffEFEFEF);
static Color getRequestStatusColor(int id){ static Color getRequestStatusColor(int id){
switch(id){ switch(id){

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
class AppStyle { class AppStyle {
AppStyle._(); AppStyle._();
static const double borderRadius = 12; static const double borderRadius = 10;
static const BoxShadow boxShadow = BoxShadow( static const BoxShadow boxShadow = BoxShadow(
color: Colors.black26, color: Colors.black26,

@ -5,6 +5,7 @@ import 'package:test_sa/controllers/http_status_manger/http_status_manger.dart';
import 'package:test_sa/controllers/providers/api/device_transfer_provider.dart'; import 'package:test_sa/controllers/providers/api/device_transfer_provider.dart';
import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/models/device/device_transfer.dart'; import 'package:test_sa/models/device/device_transfer.dart';
import 'package:test_sa/models/device/device_transfer_info.dart'; import 'package:test_sa/models/device/device_transfer_info.dart';
import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/models/subtitle.dart';
@ -18,6 +19,7 @@ import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart'; import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../../controllers/localization/localization.dart'; import '../../../../controllers/localization/localization.dart';
class RequestDeviceTransfer extends StatefulWidget { class RequestDeviceTransfer extends StatefulWidget {
static const String id = "/request-device-transfer"; static const String id = "/request-device-transfer";
const RequestDeviceTransfer({Key key}) : super(key: key); const RequestDeviceTransfer({Key key}) : super(key: key);
@ -39,20 +41,20 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override @override
void setState(VoidCallback fn){ void setState(VoidCallback fn) {
if(mounted) super.setState(() {}); if (mounted) super.setState(() {});
} }
_onSubmit() async { _onSubmit() async {
_validate = true; _validate = true;
if(!_formKey.currentState.validate()){ if (!_formKey.currentState.validate()) {
setState(() {}); setState(() {});
return false; return false;
} }
_formKey.currentState.save(); _formKey.currentState.save();
if(!_formModel.validate()) { if (!_formModel.validate()) {
setState(() { }); setState(() {});
return false; return false;
} }
@ -64,23 +66,18 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
host: _settingProvider.host, host: _settingProvider.host,
model: _formModel, model: _formModel,
); );
_isLoading =false; _isLoading = false;
setState(() {}); setState(() {});
if(status >= 200 && status < 300){ if (status >= 200 && status < 300) {
Fluttertoast.showToast( Fluttertoast.showToast(
msg: _subtitle.requestCompleteSuccessfully, msg: _subtitle.requestCompleteSuccessfully,
); );
Navigator.of(context).pop(); Navigator.of(context).pop();
}else{ } else {
String errorMessage = HttpStatusManger.getStatusMessage( String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle);
status: status, subtitle: _subtitle); ScaffoldMessenger.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar( content: Text(errorMessage),
SnackBar( ));
content: Text(
errorMessage
),
)
);
} }
} }
@ -95,7 +92,7 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
_subtitle = AppLocalization.of(context).subtitle; _subtitle = AppLocalization.of(context).subtitle;
_userProvider = Provider.of<UserProvider>(context); _userProvider = Provider.of<UserProvider>(context);
_settingProvider = Provider.of<SettingProvider>(context); _settingProvider = Provider.of<SettingProvider>(context);
_deviceTransferProvider = Provider.of<DeviceTransferProvider>(context,listen: false); _deviceTransferProvider = Provider.of<DeviceTransferProvider>(context, listen: false);
return Scaffold( return Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
body: Form( body: Form(
@ -116,11 +113,7 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Text( child: Text(
"Transfer Device", "Transfer Device",
style: Theme.of(context).textTheme.headline5.copyWith( style: Theme.of(context).textTheme.headline5.copyWith(color: Theme.of(context).primaryColor, fontSize: 28, fontWeight: FontWeight.bold),
color: Theme.of(context).primaryColor,
fontSize: 28,
fontWeight: FontWeight.bold
),
), ),
), ),
), ),
@ -138,14 +131,17 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
// _formModel.title = value; // _formModel.title = value;
// }, // },
// ), // ),
const SizedBox(height: 8,), 12.height,
const ASubTitle("Device"), const ASubTitle("Device"),
if(_validate && _formModel.device == null) if (_validate && _formModel.device == null)
ASubTitle(_subtitle.requiredWord,color: Colors.red,), ASubTitle(
const SizedBox(height: 4,), _subtitle.requiredWord,
color: Colors.red,
),
6.height,
DeviceButton( DeviceButton(
device: _formModel.device, device: _formModel.device,
onDevicePick: (device){ onDevicePick: (device) {
_formModel.device = device; _formModel.device = device;
setState(() {}); setState(() {});
}, },
@ -162,39 +158,44 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
// setState(() {}); // setState(() {});
// }, // },
// ), // ),
const SizedBox(height: 8,), 12.height,
const ASubTitle("Destination Client"), const ASubTitle("Destination Client"),
if(_validate && _formModel.receiver.client == null) if (_validate && _formModel.receiver.client == null)
ASubTitle(_subtitle.requiredWord,color: Colors.red,), ASubTitle(
const SizedBox(height: 4,), _subtitle.requiredWord,
color: Colors.red,
),
6.height,
HospitalButton( HospitalButton(
hospital: _formModel.receiver.client, hospital: _formModel.receiver.client,
onHospitalPick: (hospital){ onHospitalPick: (hospital) {
_formModel.receiver.client = hospital; _formModel.receiver.client = hospital;
setState(() {}); setState(() {});
}, },
), ),
const SizedBox(height: 8,), 12.height,
const ASubTitle("Destination Department"), const ASubTitle("Destination Department"),
if(_validate && _formModel.receiver.department == null) if (_validate && _formModel.receiver.department == null)
ASubTitle(_subtitle.requiredWord,color: Colors.red,), ASubTitle(
const SizedBox(height: 4,), _subtitle.requiredWord,
color: Colors.red,
),
6.height,
DepartmentButton( DepartmentButton(
department: _formModel.receiver.department, department: _formModel.receiver.department,
onDepartmentPick: (department){ onDepartmentPick: (department) {
_formModel.receiver.department = department; _formModel.receiver.department = department;
setState(() {}); setState(() {});
}, },
), ),
12.height,
Padding( AButton(
padding: const EdgeInsets.all(16.0), text: _subtitle.submit,
child: AButton( onPressed: _onSubmit,
text: _subtitle.submit,
onPressed: _onSubmit,
),
), ),
const SizedBox(height: 100,) const SizedBox(
height: 100,
)
], ],
), ),
), ),
@ -204,4 +205,3 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
); );
} }
} }

@ -1,7 +1,8 @@
import 'package:test_sa/controllers/api_routes/urls.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/http_status_manger/http_status_manger.dart'; import 'package:test_sa/controllers/http_status_manger/http_status_manger.dart';
import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/controllers/notification/notification_manger.dart';
import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/controllers/validator/validator.dart'; import 'package:test_sa/controllers/validator/validator.dart';
@ -12,15 +13,13 @@ import 'package:test_sa/views/pages/register.dart';
import 'package:test_sa/views/pages/user/land_page.dart'; import 'package:test_sa/views/pages/user/land_page.dart';
import 'package:test_sa/views/widgets/app_text_form_field.dart'; import 'package:test_sa/views/widgets/app_text_form_field.dart';
import 'package:test_sa/views/widgets/buttons/app_button.dart'; import 'package:test_sa/views/widgets/buttons/app_button.dart';
import 'package:test_sa/views/widgets/buttons/app_flat_button.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:provider/provider.dart';
import '../widgets/buttons/app_outlined_button.dart'; import '../widgets/buttons/app_outlined_button.dart';
class Login extends StatefulWidget { class Login extends StatefulWidget {
static final String id = "/login"; static final String id = "/login";
@override @override
_LoginState createState() => _LoginState(); _LoginState createState() => _LoginState();
} }
@ -46,7 +45,7 @@ class _LoginState extends State<Login> {
Subtitle _subtitle = AppLocalization.of(context).subtitle; Subtitle _subtitle = AppLocalization.of(context).subtitle;
return Scaffold( return Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
body:SafeArea( body: SafeArea(
child: LoadingManager( child: LoadingManager(
isLoading: _userProvider.isLoading || !_settingProvider.isLoaded, isLoading: _userProvider.isLoading || !_settingProvider.isLoaded,
isFailedLoading: false, isFailedLoading: false,
@ -59,97 +58,92 @@ class _LoginState extends State<Login> {
child: Column( child: Column(
children: [ children: [
//AppNameBar(), //AppNameBar(),
SizedBox(height: MediaQuery.of(context).size.height / 5,), SizedBox(
height: MediaQuery.of(context).size.height / 7,
),
Hero( Hero(
tag: "logo", tag: "logo",
child: Image( child: Image(
height: _height/6, height: _height / 6,
fit: BoxFit.contain, fit: BoxFit.contain,
image: AssetImage("assets/images/logo.png"), image: AssetImage("assets/images/logo.png"),
), ),
), ),
Padding( Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(horizontal: 24 * AppStyle.getScaleFactor(context), vertical: 24 * AppStyle.getScaleFactor(context)),
horizontal: 24 * AppStyle.getScaleFactor(context),
vertical: 24 * AppStyle.getScaleFactor(context)
),
child: Column( child: Column(
children: [ children: [
SizedBox(height: 24 * AppStyle.getScaleFactor(context),), SizedBox(
height: 24 * AppStyle.getScaleFactor(context),
),
ATextFormField( ATextFormField(
initialValue: _user?.userName, initialValue: _user?.userName,
hintText: _subtitle.name, hintText: _subtitle.name,
textAlign: TextAlign.center, textAlign: TextAlign.left,
style: Theme.of(context).textTheme.headline6, style: Theme.of(context).textTheme.bodyText1,
prefixIconData: Icons.account_circle, prefixIconData: Icons.account_circle,
validator: (value) => validator: (value) => Validator.hasValue(value) ? null : _subtitle.nameValidateMessage,
Validator.hasValue(value)
? null : _subtitle.nameValidateMessage,
textInputType: TextInputType.name, textInputType: TextInputType.name,
onSaved: (value){ onSaved: (value) {
_user.userName = value; _user.userName = value;
}, },
), ),
SizedBox(height: 24 * AppStyle.getScaleFactor(context),), SizedBox(height: 12),
ATextFormField( ATextFormField(
initialValue: _user?.password, initialValue: _user?.password,
hintText: _subtitle.password, hintText: _subtitle.password,
obscureText: _obscurePassword, obscureText: _obscurePassword,
style: Theme.of(context).textTheme.headline6, style: Theme.of(context).textTheme.bodyText1,
prefixIconData: Icons.vpn_key_sharp, prefixIconData: Icons.vpn_key_sharp,
textAlign: TextAlign.center, textAlign: TextAlign.left,
validator: (value) => Validator.isValidPassword(value) validator: (value) => Validator.isValidPassword(value) ? null : _subtitle.passwordValidateMessage,
? null : _subtitle.passwordValidateMessage, showPassword: () {
showPassword: (){
_obscurePassword = !_obscurePassword; _obscurePassword = !_obscurePassword;
setState(() {}); setState(() {});
}, },
onSaved: (value){ onSaved: (value) {
_user.password = value; _user.password = value;
}, },
), ),
SizedBox(height: 32 * AppStyle.getScaleFactor(context),), SizedBox(
height: 32 * AppStyle.getScaleFactor(context),
),
AButton( AButton(
text: _subtitle.signIn, text: _subtitle.signIn,
onPressed: () async { onPressed: () async {
if(!_formKey.currentState.validate()) if (!_formKey.currentState.validate()) return;
return;
_formKey.currentState.save(); _formKey.currentState.save();
int status = await _userProvider.login( int status = await _userProvider.login(
user: _user, user: _user,
host: _settingProvider.host, host: _settingProvider.host,
); );
if(status >= 200 && status < 300){ if (status >= 200 && status < 300) {
_settingProvider.setUser(_userProvider.user); _settingProvider.setUser(_userProvider.user);
if(_userProvider.user.isActive) if (_userProvider.user.isActive)
Navigator.of(context).pushNamed(LandPage.id); Navigator.of(context).pushNamed(LandPage.id);
else else
Fluttertoast.showToast(msg: _subtitle.activationAlert); Fluttertoast.showToast(msg: _subtitle.activationAlert);
}else{ } else {
String errorMessage = status == 400 String errorMessage = status == 400 ? _subtitle.wrongEmailOrPassword : HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle);
? _subtitle.wrongEmailOrPassword ScaffoldMessenger.of(context).showSnackBar(SnackBar(
: HttpStatusManger.getStatusMessage( content: Text(errorMessage),
status: status, subtitle: _subtitle); ));
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
errorMessage
),
)
);
} }
}, },
), ),
SizedBox(height: 140 * AppStyle.getScaleFactor(context),), SizedBox(
height: 140 * AppStyle.getScaleFactor(context),
),
AOutLinedButton( AOutLinedButton(
text: _subtitle.signUp, text: _subtitle.signUp,
//color: AColors.cyan, //color: AColors.cyan,
onPressed: (){ onPressed: () {
Navigator.of(context).pushNamed(Register.id); Navigator.of(context).pushNamed(Register.id);
}, },
), ),
SizedBox(
SizedBox(height: 32,), height: 32,
),
], ],
), ),
), ),

@ -1,3 +1,7 @@
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/http_status_manger/http_status_manger.dart'; import 'package:test_sa/controllers/http_status_manger/http_status_manger.dart';
import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart';
@ -5,21 +9,16 @@ import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/controllers/validator/validator.dart'; import 'package:test_sa/controllers/validator/validator.dart';
import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/models/user.dart'; import 'package:test_sa/models/user.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/app_text_form_field.dart'; import 'package:test_sa/views/widgets/app_text_form_field.dart';
import 'package:test_sa/views/widgets/buttons/app_back_button.dart'; import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
import 'package:test_sa/views/widgets/buttons/app_button.dart'; import 'package:test_sa/views/widgets/buttons/app_button.dart';
import 'package:test_sa/views/widgets/departments/department_button.dart'; import 'package:test_sa/views/widgets/departments/department_button.dart';
import 'package:test_sa/views/widgets/hospitals/hospital_button.dart'; import 'package:test_sa/views/widgets/hospitals/hospital_button.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
class Register extends StatefulWidget { class Register extends StatefulWidget {
static final String id = "/register"; static final String id = "/register";
@override @override
_RegisterState createState() => _RegisterState(); _RegisterState createState() => _RegisterState();
} }
@ -33,6 +32,7 @@ class _RegisterState extends State<Register> {
bool _obscurePassword = true; bool _obscurePassword = true;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context); _userProvider = Provider.of<UserProvider>(context);
@ -42,7 +42,7 @@ class _RegisterState extends State<Register> {
Subtitle _subtitle = AppLocalization.of(context).subtitle; Subtitle _subtitle = AppLocalization.of(context).subtitle;
return Scaffold( return Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
body:LoadingManager( body: LoadingManager(
isLoading: _userProvider.isLoading, isLoading: _userProvider.isLoading,
isFailedLoading: false, isFailedLoading: false,
stateCode: 200, stateCode: 200,
@ -53,6 +53,7 @@ class _RegisterState extends State<Register> {
Form( Form(
key: _formKey, key: _formKey,
child: ListView( child: ListView(
padding: const EdgeInsets.all(20),
children: [ children: [
//AppNameBar(), //AppNameBar(),
//SizedBox(height: 16,), //SizedBox(height: 16,),
@ -61,190 +62,143 @@ class _RegisterState extends State<Register> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Image( child: Image(
height: _height/6, height: _height / 6,
image: AssetImage("assets/images/logo.png"), image: AssetImage("assets/images/logo.png"),
), ),
), ),
), ),
Container( ATextFormField(
padding: EdgeInsets.symmetric(horizontal: 16,vertical: 16), initialValue: _user.userName,
margin: EdgeInsets.symmetric(horizontal: 16), hintText: _subtitle.name,
decoration: BoxDecoration( prefixIconData: Icons.account_circle,
color: AColors.cyan, style: Theme.of(context).textTheme.headline6,
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), validator: (value) => Validator.hasValue(value) ? null : _subtitle.nameValidateMessage,
boxShadow: [ onSaved: (value) {
BoxShadow( _user.userName = value;
color: AColors.grey, },
offset: Offset(0,-1), ),
) const SizedBox(height: 12),
] ATextFormField(
), initialValue: _user.email,
child: Column( hintText: _subtitle.email,
children: [ prefixIconData: Icons.email,
ATextFormField( textInputType: TextInputType.emailAddress,
initialValue: _user.userName, style: Theme.of(context).textTheme.headline6,
hintText: _subtitle.name, validator: (value) => Validator.isEmail(value) ? null : _subtitle.emailValidateMessage,
prefixIconData: Icons.account_circle, onSaved: (value) {
style: Theme.of(context).textTheme.headline6, _user.email = value;
validator: (value) => Validator.hasValue(value) },
? null : _subtitle.nameValidateMessage, ),
onSaved: (value){ const SizedBox(height: 12),
_user.userName = value; ATextFormField(
}, initialValue: _user.password,
), hintText: _subtitle.password,
SizedBox(height: 8,), prefixIconData: Icons.vpn_key_sharp,
ATextFormField( style: Theme.of(context).textTheme.headline6,
initialValue: _user.email, obscureText: _obscurePassword,
hintText: _subtitle.email, validator: (value) => Validator.isValidPassword(value) ? null : _subtitle.passwordValidateMessage,
prefixIconData: Icons.email, showPassword: () {
textInputType: TextInputType.emailAddress, _obscurePassword = !_obscurePassword;
style: Theme.of(context).textTheme.headline6, setState(() {});
validator: (value) => Validator.isEmail(value) },
? null : _subtitle.emailValidateMessage, onSaved: (value) {
onSaved: (value){ _user.password = value;
_user.email = value; },
}, onChange: (value) {
), _user.password = value;
SizedBox(height: 8,), },
ATextFormField( ),
initialValue: _user.password, const SizedBox(height: 12),
hintText: _subtitle.password, ATextFormField(
prefixIconData: Icons.vpn_key_sharp, initialValue: _user.password,
style: Theme.of(context).textTheme.headline6, prefixIconData: Icons.vpn_key_sharp,
obscureText: _obscurePassword, hintText: _subtitle.confirmPassword,
validator: (value) => Validator.isValidPassword(value) style: Theme.of(context).textTheme.headline6,
? null : _subtitle.passwordValidateMessage, obscureText: _obscurePassword,
showPassword: (){ validator: (value) => _user.password == value ? null : _subtitle.confirmPasswordValidateMessage,
_obscurePassword = !_obscurePassword; showPassword: () {
setState(() {}); _obscurePassword = !_obscurePassword;
}, setState(() {});
onSaved: (value){ },
_user.password = value; ),
}, const SizedBox(height: 12),
onChange: (value){ HospitalButton(
_user.password = value; hospital: _user.hospital,
}, onHospitalPick: (hospital) {
), _user.hospital = hospital;
SizedBox(height: 8,), setState(() {});
ATextFormField( },
initialValue: _user.password,
prefixIconData: Icons.vpn_key_sharp,
hintText: _subtitle.confirmPassword,
style: Theme.of(context).textTheme.headline6,
obscureText: _obscurePassword,
validator: (value) =>
_user.password == value
? null : _subtitle.confirmPasswordValidateMessage,
showPassword: (){
_obscurePassword = !_obscurePassword;
setState(() {});
},
),
SizedBox(height: 8,),
HospitalButton(
hospital: _user.hospital,
onHospitalPick: (hospital){
_user.hospital = hospital;
setState(() {});
},
),
SizedBox(height: 8,),
DepartmentButton(
department: _user.department,
onDepartmentPick: (department){
_user.department = department;
setState(() {});
},
),
SizedBox(height: 8,),
ATextFormField(
initialValue: _user.phoneNumber,
hintText: _subtitle.phoneNumber,
style: Theme.of(context).textTheme.headline6,
prefixIconData: Icons.phone_android,
validator: (value) =>
Validator.isPhoneNumber(value)
? null : _subtitle.phoneNumberValidateMessage,
textInputType: TextInputType.phone,
onSaved: (value){
_user.phoneNumber = value;
},
),
SizedBox(height: 8,),
ATextFormField(
initialValue: _user.whatsApp,
hintText: _subtitle.whatsApp,
style: Theme.of(context).textTheme.headline6,
prefixIconData: FontAwesomeIcons.whatsapp,
prefixIconSize: 36,
validator: (value) =>
Validator.isPhoneNumber(value) ? null : _subtitle.phoneNumberValidateMessage,
textInputType: TextInputType.phone,
onSaved: (value){
_user.whatsApp = value;
},
),
],
),
), ),
SizedBox(height: 16,), const SizedBox(height: 12),
Center( DepartmentButton(
child: SizedBox( department: _user.department,
height: _width / 8, onDepartmentPick: (department) {
width: _width/1.2, _user.department = department;
child: AButton( setState(() {});
text: _subtitle.signUp, },
onPressed: () async { ),
if(!_formKey.currentState.validate()) const SizedBox(height: 12),
return; ATextFormField(
_formKey.currentState.save(); initialValue: _user.phoneNumber,
if(_user.hospital == null){ hintText: _subtitle.phoneNumber,
ScaffoldMessenger.of(context).showSnackBar( style: Theme.of(context).textTheme.headline6,
SnackBar( prefixIconData: Icons.phone_android,
content: Text( validator: (value) => Validator.isPhoneNumber(value) ? null : _subtitle.phoneNumberValidateMessage,
_subtitle.hospitalRequired textInputType: TextInputType.phone,
), onSaved: (value) {
) _user.phoneNumber = value;
); },
return; ),
} SizedBox(height: 8),
if(_user.department == null){ ATextFormField(
ScaffoldMessenger.of(context).showSnackBar( initialValue: _user.whatsApp,
SnackBar( hintText: _subtitle.whatsApp,
content: Text( style: Theme.of(context).textTheme.headline6,
_subtitle.unitRequired prefixIconData: FontAwesomeIcons.whatsapp,
), prefixIconSize: 36,
) validator: (value) => Validator.isPhoneNumber(value) ? null : _subtitle.phoneNumberValidateMessage,
); textInputType: TextInputType.phone,
return; onSaved: (value) {
} _user.whatsApp = value;
int status = await _userProvider.register( },
user: _user, ),
host: _settingProvider.host, const SizedBox(height: 12),
); AButton(
if(status >= 200 && status < 300){ text: _subtitle.signUp,
Fluttertoast.showToast(msg: _subtitle.activationAlert); onPressed: () async {
Navigator.of(context).pop(); if (!_formKey.currentState.validate()) return;
}else{ _formKey.currentState.save();
String errorMessage = status == 402 if (_user.hospital == null) {
? _subtitle.nameExist ScaffoldMessenger.of(context).showSnackBar(SnackBar(
: status == 401 content: Text(_subtitle.hospitalRequired),
));
return;
}
if (_user.department == null) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(_subtitle.unitRequired),
));
return;
}
int status = await _userProvider.register(
user: _user,
host: _settingProvider.host,
);
if (status >= 200 && status < 300) {
Fluttertoast.showToast(msg: _subtitle.activationAlert);
Navigator.of(context).pop();
} else {
String errorMessage = status == 402
? _subtitle.nameExist
: status == 401
? _subtitle.emailExist ? _subtitle.emailExist
: HttpStatusManger.getStatusMessage( : HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle);
status: status, subtitle: _subtitle); ScaffoldMessenger.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar( content: Text(errorMessage),
SnackBar( ));
content: Text( }
errorMessage },
),
)
);
}
},
),
),
), ),
SizedBox(height: 32,),
], ],
), ),
), ),

@ -209,13 +209,10 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
_currentDetails.requestedQuantity = int.tryParse(value); _currentDetails.requestedQuantity = int.tryParse(value);
}, },
), ),
const SizedBox(height: 8,), const SizedBox(height: 16),
Padding( AButton(
padding: const EdgeInsets.all(16.0), text: _subtitle.add,
child: AButton( onPressed: _addNewModel,
text: _subtitle.add,
onPressed: _addNewModel,
),
), ),
if(_formModel.details.isNotEmpty) if(_formModel.details.isNotEmpty)
const ASubTitle("Gas Requests"), const ASubTitle("Gas Requests"),
@ -235,12 +232,10 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
); );
} }
), ),
Padding( const SizedBox(height: 16),
padding: const EdgeInsets.all(16.0), AButton(
child: AButton( text: _subtitle.submit,
text: _subtitle.submit, onPressed: _onSubmit,
onPressed: _onSubmit,
),
), ),
const SizedBox(height: 100,) const SizedBox(height: 100,)
], ],

@ -53,7 +53,7 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage>
Column( Column(
children: [ children: [
Container( Container(
color:AColors.primaryColor, color:AColors.white,
padding: const EdgeInsets.symmetric(horizontal: 0,vertical: 4), padding: const EdgeInsets.symmetric(horizontal: 0,vertical: 4),
child: Column( child: Column(
children: [ children: [
@ -65,7 +65,7 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage>
child: Text( child: Text(
_subtitle.serviceRequests, _subtitle.serviceRequests,
style: Theme.of(context).textTheme.headline6.copyWith( style: Theme.of(context).textTheme.headline6.copyWith(
color: AColors.white, color: AColors.grey3A,
fontStyle: FontStyle.italic fontStyle: FontStyle.italic
), ),
), ),

@ -1,5 +1,12 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:package_info/package_info.dart';
import 'package:provider/provider.dart';
import 'package:share/share.dart';
import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/controllers/notification/firebase_notification_manger.dart'; import 'package:test_sa/controllers/notification/firebase_notification_manger.dart';
import 'package:test_sa/controllers/providers/api/departments_provider.dart'; import 'package:test_sa/controllers/providers/api/departments_provider.dart';
@ -9,6 +16,8 @@ import 'package:test_sa/controllers/providers/api/regular_visits_provider.dart';
import 'package:test_sa/controllers/providers/api/service_requests_provider.dart'; import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/user_types.dart'; import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
@ -19,25 +28,17 @@ import 'package:test_sa/views/pages/user/gas_refill/request_gas_refill.dart';
import 'package:test_sa/views/pages/user/gas_refill/track_gas_refill.dart'; import 'package:test_sa/views/pages/user/gas_refill/track_gas_refill.dart';
import 'package:test_sa/views/pages/user/notifications/notifications_page.dart'; import 'package:test_sa/views/pages/user/notifications/notifications_page.dart';
import 'package:test_sa/views/pages/user/requests/create_request.dart'; import 'package:test_sa/views/pages/user/requests/create_request.dart';
import 'package:test_sa/views/pages/user/visits/preventive_maintenance_visits_page.dart';
import 'package:test_sa/views/pages/user/visits/regular_visits_page.dart'; import 'package:test_sa/views/pages/user/visits/regular_visits_page.dart';
import 'package:test_sa/views/widgets/buttons/app_back_button.dart'; import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
import 'package:test_sa/views/widgets/buttons/app_icon_button.dart'; import 'package:test_sa/views/widgets/buttons/app_icon_button.dart';
import 'package:test_sa/views/widgets/dialogs/dialog.dart'; import 'package:test_sa/views/widgets/dialogs/dialog.dart';
import 'package:test_sa/views/widgets/drawer/drawer_item.dart'; import 'package:test_sa/views/widgets/drawer/drawer_item.dart';
import 'package:test_sa/views/widgets/loaders/image_loader.dart'; import 'package:test_sa/views/widgets/loaders/image_loader.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:package_info/package_info.dart';
import 'package:provider/provider.dart';
import 'package:share/share.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import '../../widgets/land_page/land_page_item.dart'; import '../../widgets/land_page/land_page_item.dart';
import 'profile_page.dart';
import 'requests/requests_page.dart'; import 'requests/requests_page.dart';
class LandPage extends StatefulWidget { class LandPage extends StatefulWidget {
static const String id = "/land-page"; static const String id = "/land-page";
@ -64,10 +65,9 @@ class _LandPageState extends State<LandPage> {
@override @override
void initState() { void initState() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
try{ try {
FirebaseNotificationManger.initialized(context); FirebaseNotificationManger.initialized(context);
}catch(error){ } catch (error) {}
}
}); });
super.initState(); super.initState();
} }
@ -85,12 +85,9 @@ class _LandPageState extends State<LandPage> {
_preventiveMaintenanceVisitsProvider = Provider.of<PreventiveMaintenanceVisitsProvider>(context); _preventiveMaintenanceVisitsProvider = Provider.of<PreventiveMaintenanceVisitsProvider>(context);
_regularVisitsProvider = Provider.of<RegularVisitsProvider>(context); _regularVisitsProvider = Provider.of<RegularVisitsProvider>(context);
Subtitle _subtitle = AppLocalization.of(context).subtitle; Subtitle _subtitle = AppLocalization.of(context).subtitle;
if(firstTime){ if (firstTime) {
if(path != null){ if (path != null) {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed("/" + path.split("/").first, arguments: path.split("/").last);
"/"+path.split("/").first,
arguments: path.split("/").last
);
} }
firstTime = false; firstTime = false;
} }
@ -101,26 +98,25 @@ class _LandPageState extends State<LandPage> {
bool result = await showDialog( bool result = await showDialog(
context: context, context: context,
builder: (_) => AAlertDialog( builder: (_) => AAlertDialog(
title: _subtitle.exit, title: _subtitle.exit,
content: _subtitle.exitAlert, content: _subtitle.exitAlert,
) ));
); if (result == true) {
if(result == true){ if (Platform.isAndroid) {
if(Platform.isAndroid){
SystemChannels.platform.invokeMethod('SystemNavigator.pop'); SystemChannels.platform.invokeMethod('SystemNavigator.pop');
} else { } else {
exit(0); exit(0);
} }
} }
return false; return false;
}, },
child: Scaffold( child: Scaffold(
key: _scaffoldKey, key: _scaffoldKey, //backgroundColor: Color(0xffF8F8F8),
body: SafeArea( body: SafeArea(
child: Stack( child: Stack(
children: [ children: [
ListView( ListView(
padding: const EdgeInsets.all(16.0),
children: [ children: [
//AppNameBar(), //AppNameBar(),
// SizedBox( // SizedBox(
@ -141,102 +137,100 @@ class _LandPageState extends State<LandPage> {
// ) // )
// ), // ),
// ), // ),
SizedBox(height: 48 * AppStyle.getScaleFactor(context),), SizedBox(
Hero( height: 48 * AppStyle.getScaleFactor(context),
tag: "logo",
child: Image(
height: _height/6,
image: const AssetImage("assets/images/logo.png"),
),
), ),
Padding( // Hero(
padding: const EdgeInsets.all(16.0), // tag: "logo",
child: GridView.count( // child: Image(
shrinkWrap: true, // height: _height / 6,
physics: const ClampingScrollPhysics(), // image: const AssetImage("assets/images/logo.png"),
crossAxisCount: 2, // ),
crossAxisSpacing: 5, // ),
mainAxisSpacing: 5, GridView.count(
childAspectRatio: 1.15, shrinkWrap: true,
children: [ physics: const ClampingScrollPhysics(),
if (_userProvider.user.type == UsersTypes.normal_user) crossAxisCount: 2,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
childAspectRatio: 1,
children: [
if (_userProvider.user.type == UsersTypes.normal_user)
LandPageItem( LandPageItem(
text: _subtitle.newServiceRequest, text: _subtitle.newServiceRequest,
icon: FontAwesomeIcons.tools, icon: FontAwesomeIcons.tools,
onPressed: (){ onPressed: () {
Navigator.of(context).pushNamed(CreateRequestPage.id); Navigator.of(context).pushNamed(CreateRequestPage.id);
}, },
), ),
LandPageItem( LandPageItem(
text: _subtitle.trackServiceRequest, text: _subtitle.trackServiceRequest,
icon: FontAwesomeIcons.tasks, icon: FontAwesomeIcons.tasks,
onPressed: (){ onPressed: () {
Navigator.of(context).pushNamed(ServiceRequestsPage.id); Navigator.of(context).pushNamed(ServiceRequestsPage.id);
}, },
), ),
//if (_userProvider.user.type == UsersTypes.engineer) //if (_userProvider.user.type == UsersTypes.engineer)
LandPageItem( LandPageItem(
text: _subtitle.preventiveMaintenance, text: _subtitle.preventiveMaintenance,
icon: FontAwesomeIcons.personWalking, icon: FontAwesomeIcons.personWalking,
onPressed: (){ onPressed: () {
Navigator.of(context).pushNamed(RegularVisitsPage.id); Navigator.of(context).pushNamed(RegularVisitsPage.id);
}, },
), ),
//if (_userProvider.user.type == UsersTypes.engineer) //if (_userProvider.user.type == UsersTypes.engineer)
// LandPageItem( // LandPageItem(
// text: _subtitle.preventiveMaintenance, // text: _subtitle.preventiveMaintenance,
// icon: FontAwesomeIcons.toolbox, // icon: FontAwesomeIcons.toolbox,
// onPressed: (){ // onPressed: (){
// Navigator.of(context).pushNamed(PreventiveMaintenanceVisitsPage.id); // Navigator.of(context).pushNamed(PreventiveMaintenanceVisitsPage.id);
// }, // },
// ), // ),
if (_userProvider.user.type != UsersTypes.engineer) if (_userProvider.user.type != UsersTypes.engineer)
LandPageItem( LandPageItem(
text: "Request Gas Refill", text: "Request Gas Refill",
icon: FontAwesomeIcons.truckFast, icon: FontAwesomeIcons.truckFast,
onPressed: (){ onPressed: () {
Navigator.of(context).pushNamed(RequestGasRefill.id); Navigator.of(context).pushNamed(RequestGasRefill.id);
}, },
), ),
LandPageItem( LandPageItem(
text: "Track Gas Refill", text: "Track Gas Refill",
icon: Icons.content_paste_search, icon: Icons.content_paste_search,
onPressed: (){ onPressed: () {
Navigator.of(context).pushNamed(TrackGasRefillPage.id); Navigator.of(context).pushNamed(TrackGasRefillPage.id);
}, },
), ),
LandPageItem( LandPageItem(
text: "transfer Device", text: "transfer Device",
icon: FontAwesomeIcons.rightLeft, icon: FontAwesomeIcons.rightLeft,
onPressed: (){ onPressed: () {
Navigator.of(context).pushNamed(RequestDeviceTransfer.id); Navigator.of(context).pushNamed(RequestDeviceTransfer.id);
}, },
), ),
LandPageItem( LandPageItem(
text: "Track Device Transfer", text: "Track Device Transfer",
icon: FontAwesomeIcons.peopleCarryBox, icon: FontAwesomeIcons.peopleCarryBox,
onPressed: (){ onPressed: () {
Navigator.of(context).pushNamed(TrackDeviceTransferPage.id); Navigator.of(context).pushNamed(TrackDeviceTransferPage.id);
}, },
), ),
], ],
),
), ),
SizedBox(height: 100,)
], ],
), ),
Align( Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: ABackButton( child: ABackButton(
icon: Icons.power_settings_new_rounded,
onPressed: () async { onPressed: () async {
bool result = await showDialog( bool result = await showDialog(
context: context, context: context,
builder: (_) => AAlertDialog( builder: (_) => AAlertDialog(
title: _subtitle.signOut, title: _subtitle.signOut,
content: _subtitle.signOutAlert, content: _subtitle.signOutAlert,
) ));
); if (result) {
if(result){
_devicesProvider.reset(); _devicesProvider.reset();
_departmentsProvider.reset(); _departmentsProvider.reset();
_serviceRequestsProvider.reset(); _serviceRequestsProvider.reset();
@ -251,213 +245,152 @@ class _LandPageState extends State<LandPage> {
Align( Align(
alignment: Alignment.topRight, alignment: Alignment.topRight,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
horizontal: 8,
vertical: 4
),
child: AIconButton( child: AIconButton(
iconData: Icons.menu, iconData: Icons.menu,
color: AColors.primaryColor, color: AColors.primaryColor,
buttonSize: 42, buttonSize: 42,
backgroundColor: AColors.white, backgroundColor: AColors.white,
onPressed: (){ onPressed: () {
_scaffoldKey.currentState.openEndDrawer(); _scaffoldKey.currentState.openEndDrawer();
}, },
), ),
), ),
), ),
Align(
alignment: Alignment.bottomCenter,
child: Container(
padding: EdgeInsets.all(16),
color: AColors.primaryColor,
child: Row(
children: [
AIconButton(
iconData: Icons.mail,
onPressed: (){
launch("mailto:customerservice@Test SA.com");
},
),
Expanded(
child: MaterialButton(
splashColor: AColors.secondaryColor.withOpacity(.5),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.all(12),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
8 * AppStyle.getScaleFactor(context)
),
color: AColors.onPrimaryColor
),
child: Icon(
Icons.phone_in_talk,
color: AColors.primaryColor ,
size: 32,
),
),
SizedBox(
width: 12 * AppStyle.getScaleFactor(context),
),
Text(
"${_subtitle.hotLine}\n15564",
style: Theme.of(context).textTheme.headline6.copyWith(
color: AColors.white,
letterSpacing: 2.75,
fontWeight: FontWeight.bold
),
),
],
),
onPressed: (){
launch("tel:15564");
},
),
),
AIconButton(
iconData: Icons.notifications,
onPressed: (){
Navigator.of(context).pushNamed(NotificationsPage.id);
},
),
],
),
),
),
], ],
), ),
), ),
endDrawer: Drawer( endDrawer: Drawer(
child: Container( backgroundColor: Colors.white,
color: AColors.primaryColor, child: Column(
child: Column( children: [
children: [ 40.height,
SizedBox( Row(
width: MediaQuery.of(context).size.width, mainAxisAlignment: MainAxisAlignment.end,
child: DrawerHeader( children: [
decoration: BoxDecoration( const Icon(Icons.clear).onPress(() => Navigator.pop(context)),
color: Theme.of(context).colorScheme.onPrimary, ],
), ).paddingOnly(left: 4, right: 14),
padding: EdgeInsets.zero, Row(
child: MaterialButton( children: [
padding: EdgeInsets.zero, Container(
onPressed: (){ height: 50 * AppStyle.getScaleFactor(context),
Navigator.of(context).pop(); width: 50 * AppStyle.getScaleFactor(context),
Navigator.of(context).pushNamed(ProfilePage.id); padding: EdgeInsets.all(4),
decoration: BoxDecoration(border: Border.all(color: Theme.of(context).primaryColor, width: 2), shape: BoxShape.circle),
}, child: ClipOval(
child: Column( child: ImageLoader(
mainAxisAlignment: MainAxisAlignment.center, url: "https://cdn.business2community.com/wp-content/uploads/2017/08/blank-profile-picture-973460_640.png",
children: [
Container(
height: 100 * AppStyle.getScaleFactor(context),
width: 100 * AppStyle.getScaleFactor(context),
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
border: Border.all(
color: Theme.of(context).primaryColor,
width: 2
),
shape: BoxShape.circle
),
child: ClipOval(
child: ImageLoader(
url: "https://cdn.business2community.com/wp-content/uploads/2017/08/blank-profile-picture-973460_640.png",
),
),
),
Text(
_userProvider.user.userName,
style: Theme.of(context).textTheme.headline6.copyWith(
fontWeight: FontWeight.normal,
),
textScaleFactor: AppStyle.getScaleFactor(context),
),
],
), ),
), ),
), ),
), 12.width,
Row( Text(
children: [ _userProvider.user.userName,
Radio( style: Theme.of(context).textTheme.headline6.copyWith(
value: "en", fontWeight: FontWeight.w600,
activeColor: Colors.white, ),
focusColor: Colors.white, textScaleFactor: AppStyle.getScaleFactor(context),
groupValue: _settingProvider.language, ).expanded
onChanged: (value){ ],
_settingProvider.setLanguage(value); ).paddingOnly(left: 14, right: 14, top: 21, bottom: 21),
} Divider(
), height: 1,
Text( thickness: 1,
"English", color: AColors.greyEF,
style: Theme.of(context).textTheme.bodyText1.copyWith( ),
color: Colors.white ListView(
children: [
Row(
children: [
Radio(
value: "en",
activeColor: AColors.grey3A,
focusColor: AColors.grey3A,
groupValue: _settingProvider.language,
onChanged: (value) {
_settingProvider.setLanguage(value);
}),
Text(
"English",
style: Theme.of(context).textTheme.bodyText1.copyWith(color: AColors.grey3A),
textScaleFactor: AppStyle.getScaleFactor(context),
), ),
textScaleFactor: AppStyle.getScaleFactor(context), Radio(
), value: "ar",
Radio( activeColor: AColors.grey3A,
value: "ar", focusColor: AColors.grey3A,
activeColor: Colors.white, groupValue: _settingProvider.language,
focusColor: Colors.white, onChanged: (value) {
groupValue: _settingProvider.language, _settingProvider.setLanguage(value);
onChanged: (value){ }),
_settingProvider.setLanguage(value); Text(
} "عربي",
), style: Theme.of(context).textTheme.bodyText1.copyWith(color: AColors.grey3A),
Text( textScaleFactor: AppStyle.getScaleFactor(context),
"عربي",
style: Theme.of(context).textTheme.bodyText1.copyWith(
color: Colors.white
), ),
textScaleFactor: AppStyle.getScaleFactor(context), ],
), ),
], DrawerItem(
), icon: Icons.notifications,
DrawerItem( title: _subtitle.notifications,
icon: FontAwesomeIcons.linkedinIn, onPressed: () {
title: _subtitle.linkedIn, Navigator.of(context).pushNamed(NotificationsPage.id);
onPressed: (){ },
launch("https://www.linkedin.com/company/Test SA/"); ),
}, DrawerItem(
), icon: Icons.mail,
DrawerItem( title: _subtitle.email,
icon: FontAwesomeIcons.globe, onPressed: () {
title: _subtitle.ourWebsite, launch("mailto:customerservice@Test SA.com");
onPressed: (){ },
launch("https://www.Test SA.com/"); ),
}, DrawerItem(
), icon: Icons.phone_in_talk,
DrawerItem( title: "${_subtitle.hotLine} 15564",
icon: Icons.share, onPressed: () {
title: _subtitle.shareApp, launch("tel:15564");
onPressed: () async { },
PackageInfo packageInfo = await PackageInfo.fromPlatform(); ),
String shareLink = DrawerItem(
"\n https://play.google.com/store/apps/details?id=" + packageInfo.packageName icon: FontAwesomeIcons.linkedinIn,
+ "\n https://apps.apple.com/us/app/"; title: _subtitle.linkedIn,
Share.share(shareLink); onPressed: () {
}, launch("https://www.linkedin.com/company/Test SA/");
), },
Expanded(child: Center(child: Image.asset("assets/images/qr.jpeg"))), ),
Padding( DrawerItem(
padding: const EdgeInsets.all(8.0), icon: FontAwesomeIcons.globe,
child: Text( title: _subtitle.ourWebsite,
onPressed: () {
launch("https://www.Test SA.com/");
},
),
DrawerItem(
icon: Icons.share,
title: _subtitle.shareApp,
onPressed: () async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String shareLink = "\n https://play.google.com/store/apps/details?id=" + packageInfo.packageName + "\n https://apps.apple.com/us/app/";
Share.share(shareLink);
},
),
],
).expanded,
Divider(height: 1, thickness: 1, color: AColors.greyEF),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Powered By NewTrack", "Powered By NewTrack",
style: Theme.of(context).textTheme.bodyText2.copyWith( style: Theme.of(context).textTheme.headline6.copyWith(fontWeight: FontWeight.w500, color: AColors.grey3A, fontSize: 12),
fontWeight: FontWeight.normal,
color: AColors.white
),
textScaleFactor: AppStyle.getScaleFactor(context), textScaleFactor: AppStyle.getScaleFactor(context),
), ),
), 6.width,
], Image.asset("assets/images/qr.jpeg", width: 32, height: 32, color: AColors.grey3A)
), ],
).paddingOnly(left: 20, right: 20, top: 8, bottom: 8),
],
), ),
), ),
), ),

@ -11,11 +11,12 @@ import 'package:test_sa/controllers/providers/api/service_requests_provider.dart
import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/controllers/validator/validator.dart'; import 'package:test_sa/controllers/validator/validator.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/device/device.dart'; import 'package:test_sa/models/device/device.dart';
import 'package:test_sa/models/service_request/service_request.dart'; import 'package:test_sa/models/service_request/service_request.dart';
import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/app_text_form_field.dart'; import 'package:test_sa/views/widgets/app_text_form_field.dart';
import 'package:test_sa/views/widgets/buttons/app_back_button.dart'; import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
import 'package:test_sa/views/widgets/buttons/app_button.dart'; import 'package:test_sa/views/widgets/buttons/app_button.dart';
@ -24,14 +25,15 @@ import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/sound/record_sound.dart'; import 'package:test_sa/views/widgets/sound/record_sound.dart';
import 'package:test_sa/views/widgets/speech_to_text/speech_to_text.dart'; import 'package:test_sa/views/widgets/speech_to_text/speech_to_text.dart';
class CreateRequestPage extends StatefulWidget { class CreateRequestPage extends StatefulWidget {
static final String id = "/create-request"; static final String id = "/create-request";
@override @override
_CreateRequestPageState createState() => _CreateRequestPageState(); _CreateRequestPageState createState() => _CreateRequestPageState();
} }
class _CreateRequestPageState extends State<CreateRequestPage> { class _CreateRequestPageState extends State<CreateRequestPage> {
double _height; double _height;
UserProvider _userProvider; UserProvider _userProvider;
SettingProvider _settingProvider; SettingProvider _settingProvider;
@ -56,6 +58,7 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
_controller.dispose(); _controller.dispose();
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_height = MediaQuery.of(context).size.height; _height = MediaQuery.of(context).size.height;
@ -78,11 +81,13 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
ListView( ListView(
children: [ children: [
//AppNameBar(), //AppNameBar(),
SizedBox(height: 16,), SizedBox(
height: 16,
),
Hero( Hero(
tag: "logo", tag: "logo",
child: Image( child: Image(
height: _height/6, height: _height / 6,
image: AssetImage("assets/images/logo.png"), image: AssetImage("assets/images/logo.png"),
), ),
), ),
@ -91,104 +96,80 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Text( child: Text(
_subtitle.newServiceRequest, _subtitle.newServiceRequest,
style: Theme.of(context).textTheme.headline5.copyWith( style: Theme.of(context).textTheme.headline5.copyWith(color: AColors.cyan, fontWeight: FontWeight.w600),
color: AColors.cyan,
fontWeight: FontWeight.bold
),
), ),
), ),
), ),
Container( Column(
padding: EdgeInsets.symmetric(horizontal: 16), crossAxisAlignment: CrossAxisAlignment.start,
margin: EdgeInsets.symmetric(horizontal: 16), children: [
decoration: BoxDecoration( 12.height,
color: AColors.grey, _userProvider.user.hospital == null
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), ? SizedBox.shrink()
boxShadow: const [ : ATextFormField(
BoxShadow( enable: false,
color: AColors.grey, initialValue: _userProvider.user.hospital?.name ?? _subtitle.noHospitalFound,
offset: Offset(0,-1), hintText: _subtitle.hospital,
) prefixIconData: FontAwesomeIcons.hospital,
] style: Theme.of(context).textTheme.headline6,
), ),
child: Column( 12.height,
crossAxisAlignment: CrossAxisAlignment.start, _userProvider.user.department == null
children: [ ? SizedBox.shrink()
const SizedBox(height: 8,), : ATextFormField(
_userProvider.user.hospital == null ? SizedBox.shrink() : enable: false,
ATextFormField( initialValue: _userProvider.user.department?.name ?? _subtitle.noUniteFound,
enable: false, hintText: _subtitle.unite,
initialValue: _userProvider.user.hospital?.name ?? _subtitle.noHospitalFound, prefixIconData: FontAwesomeIcons.hospitalUser,
hintText: _subtitle.hospital, style: Theme.of(context).textTheme.headline6,
prefixIconData: FontAwesomeIcons.hospitalAlt, ),
prefixIconSize: 36, 12.height,
style: Theme.of(context).textTheme.headline6, DeviceButton(
), device: _device,
const SizedBox(height: 8,), onDevicePick: (device) {
_userProvider.user.department == null ? SizedBox.shrink() : _device = device;
ATextFormField( setState(() {});
enable: false, },
initialValue: _userProvider.user.department?.name ?? _subtitle.noUniteFound, ),
hintText: _subtitle.unite, 12.height,
prefixIconData: FontAwesomeIcons.hospitalUser, MultiImagesPicker(
prefixIconSize: 36, label: _subtitle.deviceImages,
style: Theme.of(context).textTheme.headline6, images: _deviceImages,
), ),
const SizedBox(height: 8,), 12.height,
DeviceButton( SpeechToTextButton(controller: _controller),
device: _device, 12.height,
onDevicePick: (device){ ATextFormField(
_device = device; controller: _controller,
setState(() {}); initialValue: _serviceRequest.maintenanceIssue,
}, hintText: _subtitle.maintenanceIssue,
), prefixIconData: FontAwesomeIcons.triangleExclamation,
MultiImagesPicker( style: Theme.of(context).textTheme.headline6,
label: _subtitle.deviceImages, textInputType: TextInputType.multiline,
images: _deviceImages, validator: (value) => Validator.hasValue(value) ? null : _subtitle.maintenanceIssueRequired,
), onSaved: (value) {
const SizedBox(height: 8,), _serviceRequest.maintenanceIssue = value;
SpeechToTextButton( },
controller: _controller, ),
), 12.height,
const SizedBox(height: 8,), RecordSound(onRecord: (audio) {
ATextFormField( _serviceRequest.audio = audio;
controller: _controller, }),
initialValue: _serviceRequest.maintenanceIssue, 12.height,
hintText: _subtitle.maintenanceIssue, ],
prefixIconData: FontAwesomeIcons.exclamationTriangle, ).paddingOnly(left: 20, right: 20),
prefixIconSize: 36,
style: Theme.of(context).textTheme.headline6,
textInputType: TextInputType.multiline,
validator: (value) => Validator.hasValue(value)
? null : _subtitle.maintenanceIssueRequired,
onSaved: (value){
_serviceRequest.maintenanceIssue = value;
},
),
const SizedBox(height: 8,),
RecordSound(
onRecord: (audio){
_serviceRequest.audio = audio;
}
),
const SizedBox(height: 8,),
],
),
),
Padding( Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(20.0),
child: AButton( child: AButton(
text: _subtitle.submit, text: _subtitle.submit,
onPressed: () async { onPressed: () async {
if(!_formKey.currentState.validate()) if (!_formKey.currentState.validate()) return;
return;
_formKey.currentState.save(); _formKey.currentState.save();
_serviceRequest.deviceId = _device?.id ?? ""; _serviceRequest.deviceId = _device?.id ?? "";
_isLoading =true; _isLoading = true;
setState(() {}); setState(() {});
_serviceRequest.devicePhotos = _deviceImages.map( _serviceRequest.devicePhotos = _deviceImages.map((e) => base64Encode(e.readAsBytesSync())).toList();
(e) => base64Encode(e.readAsBytesSync())).toList(); if (_serviceRequest.audio != null) {
if(_serviceRequest.audio != null){
final file = File(_serviceRequest.audio); final file = File(_serviceRequest.audio);
_serviceRequest.audio = base64Encode(file.readAsBytesSync()); _serviceRequest.audio = base64Encode(file.readAsBytesSync());
} }
@ -198,23 +179,18 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
host: _settingProvider.host, host: _settingProvider.host,
serviceRequest: _serviceRequest, serviceRequest: _serviceRequest,
); );
_isLoading =false; _isLoading = false;
setState(() {}); setState(() {});
if(status >= 200 && status < 300){ if (status >= 200 && status < 300) {
Fluttertoast.showToast( Fluttertoast.showToast(
msg: _subtitle.requestCompleteSuccessfully, msg: _subtitle.requestCompleteSuccessfully,
); );
Navigator.of(context).pop(); Navigator.of(context).pop();
}else{ } else {
String errorMessage = HttpStatusManger.getStatusMessage( String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle);
status: status, subtitle: _subtitle); ScaffoldMessenger.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar( content: Text(errorMessage),
SnackBar( ));
content: Text(
errorMessage
),
)
);
} }
}, },
), ),

@ -1,6 +1,6 @@
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:test_sa/views/app_style/sizing.dart';
class ATextFormField extends StatefulWidget { class ATextFormField extends StatefulWidget {
final Function(String) onSaved; final Function(String) onSaved;
final Function(String) validator; final Function(String) validator;
@ -22,57 +22,51 @@ class ATextFormField extends StatefulWidget {
final TextInputAction textInputAction; final TextInputAction textInputAction;
final VoidCallback onAction; final VoidCallback onAction;
const ATextFormField({ const ATextFormField(
Key key, {Key key,
this.onSaved, this.onSaved,
this.validator, this.validator,
this.node, this.node,
this.onChange, this.onChange,
this.obscureText, this.obscureText,
this.showPassword, this.showPassword,
this.hintText, this.hintText,
this.labelText, this.labelText,
this.textInputType = TextInputType.text, this.textInputType = TextInputType.text,
this.initialValue, this.initialValue,
this.enable = true, this.enable = true,
this.style, this.style,
this.textAlign, this.textAlign,
this.suffixIcon, this.suffixIcon,
this.prefixIconData, this.prefixIconData,
this.prefixIconSize, this.prefixIconSize,
this.controller, this.controller,
this.textInputAction, this.textInputAction,
this.onAction this.onAction})
}) : super(key: key); : super(key: key);
@override @override
State<ATextFormField> createState() => _ATextFormFieldState(); State<ATextFormField> createState() => _ATextFormFieldState();
} }
class _ATextFormFieldState extends State<ATextFormField> { class _ATextFormFieldState extends State<ATextFormField> {
@override @override
void initState() { void initState() {
if(widget.controller != null) if (widget.controller != null) widget.controller.text = widget.initialValue;
widget.controller.text = widget.initialValue;
super.initState(); super.initState();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
padding: EdgeInsets.symmetric( height: widget.textInputType == TextInputType.multiline ? null : 50,
horizontal: 16 padding: EdgeInsets.only(left: 12, right: 12),
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Color(0xfff5f5f5),
border: Border.all(color:AColors.black), border: Border.all(
borderRadius: BorderRadius.circular( color: Color(0xffefefef),
AppStyle.borderRadius * AppStyle.getScaleFactor(context)
), ),
boxShadow: [ borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
AppStyle.boxShadow
]
), ),
child: TextFormField( child: TextFormField(
focusNode: widget.node, focusNode: widget.node,
@ -81,33 +75,32 @@ class _ATextFormFieldState extends State<ATextFormField> {
initialValue: widget.controller != null ? null : widget.initialValue, initialValue: widget.controller != null ? null : widget.initialValue,
validator: widget.validator, validator: widget.validator,
onChanged: widget.onChange, onChanged: widget.onChange,
textAlign: widget.textAlign ?? TextAlign.center, textAlign: TextAlign.left,
obscureText: widget.obscureText ?? false, obscureText: widget.obscureText ?? false,
keyboardType: widget.textInputType, keyboardType: widget.textInputType,
maxLines: widget.textInputType == TextInputType.multiline ? null : 1, maxLines: widget.textInputType == TextInputType.multiline ? null : 1,
obscuringCharacter: "", obscuringCharacter: "",
controller: widget.controller, controller: widget.controller,
textInputAction: textInputAction: widget.textInputType == TextInputType.multiline ? null : widget.textInputAction ?? TextInputAction.next,
widget.textInputType == TextInputType.multiline ? null : widget.textInputAction ?? TextInputAction.next,
onEditingComplete: widget.onAction ?? () => FocusScope.of(context).nextFocus(), onEditingComplete: widget.onAction ?? () => FocusScope.of(context).nextFocus(),
style: widget.style, // style: widget.style,
style: Theme.of(context).textTheme.bodyText1,
decoration: InputDecoration( decoration: InputDecoration(
border: InputBorder.none, border: InputBorder.none,
disabledBorder: InputBorder.none, suffixIconConstraints: BoxConstraints(minWidth: 0),
focusedBorder: InputBorder.none, disabledBorder: InputBorder.none,
enabledBorder: InputBorder.none, focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
hintText: widget.hintText, constraints: BoxConstraints(),
labelText: widget.labelText, errorStyle: TextStyle(height: 0.3),
suffixIcon: widget.suffixIcon, //contentPadding: EdgeInsets.only(left: 0),
prefixIcon: widget.prefixIconData == null ? null : Icon( hintText: widget.hintText,
widget.prefixIconData, labelText: widget.labelText,
size: widget.prefixIconSize == null //suffixIcon: widget.suffixIcon,
? 32 * AppStyle.getScaleFactor(context) suffixIcon: widget.prefixIconData == null
: (widget.prefixIconSize - 10) * AppStyle.getScaleFactor(context), ? null
color: AColors.black, : Icon(widget.prefixIconData,
) size: widget.prefixIconSize == null ? 20 * AppStyle.getScaleFactor(context) : (widget.prefixIconSize - 10) * AppStyle.getScaleFactor(context), color: Color(0xff2e303a))),
),
), ),
); );
} }

@ -1,29 +1,28 @@
import 'package:test_sa/views/app_style/colors.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:test_sa/views/app_style/colors.dart';
import 'app_icon_button.dart'; import 'app_icon_button.dart';
class ABackButton extends StatelessWidget { class ABackButton extends StatelessWidget {
final VoidCallback onPressed; final VoidCallback onPressed;
final IconData icon;
const ABackButton({Key key, this.onPressed,this.icon}) : super(key: key);
const ABackButton({Key key, this.onPressed}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 16),
vertical: 4,
horizontal: 16
),
child: AIconButton( child: AIconButton(
color: AColors.white, color: AColors.white,
backgroundColor: AColors.green, backgroundColor: AColors.primaryColor,
iconData: FontAwesomeIcons.reply, iconData: icon ?? Icons.arrow_back_ios_new,
iconSize: 24, iconSize: 24,
buttonSize: 42, buttonSize: 40,
onPressed: onPressed ?? (){ onPressed: onPressed ??
Navigator.of(context).pop(); () {
}, Navigator.of(context).pop();
},
), ),
); );
} }

@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/app_style/sizing.dart';
import 'package:flutter/material.dart';
class AButton extends StatelessWidget { class AButton extends StatelessWidget {
final String text; final String text;
@ -10,40 +10,26 @@ class AButton extends StatelessWidget {
final TextStyle textStyle; final TextStyle textStyle;
final VoidCallback onPressed; final VoidCallback onPressed;
const AButton({ const AButton({Key key, this.color = AColors.primaryColor, this.text, this.padding, this.onPressed, this.textStyle}) : super(key: key);
Key key,
this.color = AColors.primaryColor,
this.text,
this.padding,
this.onPressed,
this.textStyle
}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return SizedBox(
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
foregroundColor: color.computeLuminance() > 0.5 elevation: 0,
? AColors.black : Colors.white, foregroundColor: color.computeLuminance() > 0.5 ? AColors.black : Colors.white,
backgroundColor: color, backgroundColor: color,
padding: padding ?? const EdgeInsets.symmetric(vertical: 12), padding: padding ?? const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context))),
borderRadius: BorderRadius.circular(
AppStyle.getBorderRadius(context)
)
),
), ),
onPressed: onPressed, onPressed: onPressed,
child: Text( child: Text(
text??"", text ?? "",
style: textStyle style: textStyle ?? Theme.of(context).textTheme.subtitle2.copyWith(color: AColors.white, fontSize: 14,fontWeight: FontWeight.w600),
?? Theme.of(context).textTheme.subtitle2.copyWith(
color: AColors.white,
fontSize: 18
),
textScaleFactor: AppStyle.getScaleFactor(context), textScaleFactor: AppStyle.getScaleFactor(context),
) ),
), ),
); );
} }

@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/app_style/sizing.dart';
import 'package:flutter/material.dart';
class AOutLinedButton extends StatelessWidget { class AOutLinedButton extends StatelessWidget {
final String text; final String text;
@ -9,42 +9,36 @@ class AOutLinedButton extends StatelessWidget {
final TextStyle textStyle; final TextStyle textStyle;
final VoidCallback onPressed; final VoidCallback onPressed;
const AOutLinedButton({ const AOutLinedButton({Key key, this.color = AColors.primaryColor, this.text, this.padding, this.onPressed, this.textStyle}) : super(key: key);
Key key,
this.color = AColors.primaryColor,
this.text,
this.padding,
this.onPressed,
this.textStyle
}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return OutlinedButton( return OutlinedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
padding: padding ?? EdgeInsets.symmetric(vertical: 12), padding: padding ?? EdgeInsets.symmetric(vertical: 12),
textStyle: textStyle textStyle: textStyle ?? Theme
?? Theme.of(context).textTheme.subtitle2.copyWith( .of(context)
fontSize: 18 .textTheme
.subtitle2
.copyWith(fontSize: 18),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context))),
), ),
shape: RoundedRectangleBorder( onPressed: onPressed,
borderRadius: BorderRadius.circular( child: Row(
AppStyle.getBorderRadius(context) children: [
) Expanded(
), child: Text(
), text ?? "",
onPressed: onPressed, style: Theme
child: Row( .of(context)
children: [ .textTheme
Expanded( .subtitle2
child: Text( .copyWith(color: AColors.primaryColor, fontSize: 14, fontWeight: FontWeight.w600),
text??"", textAlign: TextAlign.center,
textScaleFactor: AppStyle.getScaleFactor(context),
textAlign: TextAlign.center, ),
textScaleFactor: AppStyle.getScaleFactor(context),
), ),
), ],
], ));
)
);
} }
} }

@ -1,64 +1,50 @@
import 'package:flutter/material.dart';
import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/models/department.dart'; import 'package:test_sa/models/department.dart';
import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/departments/single_department_picker.dart'; import 'package:test_sa/views/widgets/departments/single_department_picker.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class DepartmentButton extends StatelessWidget { class DepartmentButton extends StatelessWidget {
final Function(Department) onDepartmentPick; final Function(Department) onDepartmentPick;
final Department department; final Department department;
const DepartmentButton({ const DepartmentButton({Key key, this.department, this.onDepartmentPick}) : super(key: key);
Key key,
this.department,
this.onDepartmentPick
}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Subtitle _subtitle = AppLocalization.of(context).subtitle; Subtitle _subtitle = AppLocalization.of(context).subtitle;
return ElevatedButton( return ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
padding: EdgeInsets.symmetric(horizontal: 16,vertical: 12), elevation: 0,
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular( borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
AppStyle.borderRadius * AppStyle.getScaleFactor(context)
),
side: BorderSide(
color: AColors.black
)
), ),
foregroundColor: AColors.primaryColor, foregroundColor: AColors.primaryColor,
backgroundColor: AColors.white, backgroundColor: AColors.inputFieldBackgroundColor,
), ),
child: Row( child: Row(
children: [ children: [
FaIcon(
FontAwesomeIcons.hospitalUser,
size: 28,
color: AColors.black,
),
Expanded( Expanded(
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 6), padding: const EdgeInsets.symmetric(horizontal: 8),
child: Text( child: Text(
department?.name ?? _subtitle.pickUnite, department?.name ?? _subtitle.pickUnite,
style: Theme.of(context).textTheme.subtitle1, style: Theme.of(context).textTheme.bodyText1,
textScaleFactor: AppStyle.getScaleFactor(context), textScaleFactor: AppStyle.getScaleFactor(context),
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
textAlign: TextAlign.center, textAlign: TextAlign.left,
), ),
), ),
), ),
const Icon(Icons.keyboard_arrow_down, size: 28, color: AColors.grey3A),
], ],
), ),
onPressed: () async { onPressed: () async {
Department _department = await Navigator.of(context).pushNamed(SingleDepartmentPicker.id) as Department; Department _department = await Navigator.of(context).pushNamed(SingleDepartmentPicker.id) as Department;
onDepartmentPick(_department); onDepartmentPick(_department);
} });
);
} }
} }

@ -1,48 +1,39 @@
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
class DrawerItem extends StatelessWidget { class DrawerItem extends StatelessWidget {
final String title; final String title;
final IconData icon; final IconData icon;
final VoidCallback onPressed; final VoidCallback onPressed;
const DrawerItem({Key key, this.title, this.icon, this.onPressed}) : super(key: key); const DrawerItem({Key key, this.title, this.icon, this.onPressed}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(0.0),
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
shape: RoundedRectangleBorder( elevation: 0,
borderRadius: BorderRadius.circular( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context))),
AppStyle.getBorderRadius(context)
)
),
primary: Theme.of(context).colorScheme.onPrimary, primary: Theme.of(context).colorScheme.onPrimary,
), ),
onPressed: onPressed, onPressed: onPressed,
child: Row( child: Row(
children: [ children: [
Padding( Icon(icon, color: AColors.grey3A,size: 20),
padding: const EdgeInsets.all(8.0), 12.width,
child: SizedBox(
width: 48,
child: Icon(
icon, color: Theme.of(context).colorScheme.primary
),
),
),
Text( Text(
title, title,
style: Theme.of(context).textTheme.headline6.copyWith( style: Theme.of(context).textTheme.headline6.copyWith(fontSize: 14, color: AColors.grey3A),
fontSize: 16,
color: Theme.of(context).colorScheme.primary
),
textScaleFactor: AppStyle.getScaleFactor(context), textScaleFactor: AppStyle.getScaleFactor(context),
), ),
], ],
), ).paddingOnly(left: 20,right: 20),
), ),
); );
} }

@ -1,86 +1,78 @@
import 'package:flutter/material.dart';
import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/models/device/device.dart'; import 'package:test_sa/models/device/device.dart';
import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/equipment/single_device_picker.dart'; import 'package:test_sa/views/widgets/equipment/single_device_picker.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class DeviceButton extends StatelessWidget { class DeviceButton extends StatelessWidget {
final Function(Device) onDevicePick; final Function(Device) onDevicePick;
final Device device; final Device device;
const DeviceButton({ const DeviceButton({Key key, this.device, this.onDevicePick}) : super(key: key);
Key key,
this.device,
this.onDevicePick
}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Subtitle _subtitle = AppLocalization.of(context).subtitle; Subtitle _subtitle = AppLocalization.of(context).subtitle;
return ElevatedButton( return ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
padding: EdgeInsets.symmetric(horizontal: 16,vertical: device == null ? 12 : 8), elevation: 0,
shape: RoundedRectangleBorder( padding: EdgeInsets.symmetric(horizontal: 16, vertical: device == null ? 12 : 8),
borderRadius: BorderRadius.circular( shape: RoundedRectangleBorder(
AppStyle.borderRadius * AppStyle.getScaleFactor(context) borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
), ),
side: BorderSide( foregroundColor: AColors.primaryColor,
color: AColors.black backgroundColor: AColors.inputFieldBackgroundColor,
)
), ),
onPrimary: AColors.primaryColor,
primary: AColors.white,
),
child: Row( child: Row(
children: [ children: [
FaIcon( device == null
FontAwesomeIcons.hardDrive, ? Expanded(
size: 28, child: Padding(
color: AColors.black, padding: const EdgeInsets.symmetric(horizontal: 6),
), child: Text(
device == null ? _subtitle.pickDevice,
Expanded( style: Theme.of(context).textTheme.subtitle1,
child: Padding( textScaleFactor: AppStyle.getScaleFactor(context),
padding: const EdgeInsets.symmetric(horizontal: 6), textDirection: TextDirection.rtl,
child: Text( textAlign: TextAlign.left,
_subtitle.pickDevice, ),
style: Theme.of(context).textTheme.subtitle1,
textScaleFactor: AppStyle.getScaleFactor(context),
textDirection: TextDirection.rtl,
textAlign: TextAlign.center,
),
),
):
Expanded(
child: ListTile(
title: Text("${_subtitle.sn} : " + device.serialNumber,
style: Theme.of(context).textTheme.subtitle1,
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Divider(color: Theme.of(context).textTheme.subtitle1.color,),
Text("${_subtitle.brand} : " + device.brand,
style: Theme.of(context).textTheme.subtitle2,
), ),
Divider(color: Theme.of(context).textTheme.subtitle1.color,), )
Text("${_subtitle.model} : " + device.model, : Expanded(
style: Theme.of(context).textTheme.subtitle2, child: ListTile(
contentPadding: EdgeInsets.all(0),
title: Text(
"${_subtitle.sn} : " + device.serialNumber,
style: Theme.of(context).textTheme.subtitle1,
), ),
], subtitle: Column(
), crossAxisAlignment: CrossAxisAlignment.start,
) children: [
) Divider(
color: Theme.of(context).textTheme.subtitle1.color,
),
Text(
"${_subtitle.brand} : " + device.brand,
style: Theme.of(context).textTheme.subtitle2,
),
Divider(
color: Theme.of(context).textTheme.subtitle1.color,
),
Text(
"${_subtitle.model} : " + device.model,
style: Theme.of(context).textTheme.subtitle2,
),
],
),
)),
const Icon(Icons.keyboard_arrow_down, size: 28, color: AColors.grey3A),
], ],
), ),
onPressed: () async { onPressed: () async {
Device _device = await Navigator.of(context).pushNamed(SingleDevicePicker.id) as Device; Device _device = await Navigator.of(context).pushNamed(SingleDevicePicker.id) as Device;
onDevicePick(_device); onDevicePick(_device);
} });
);
} }
} }

@ -1,3 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/controllers/providers/api/hospitals_provider.dart'; import 'package:test_sa/controllers/providers/api/hospitals_provider.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
@ -6,9 +9,7 @@ import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/hospitals/hospital_item.dart'; import 'package:test_sa/views/widgets/hospitals/hospital_item.dart';
import 'package:flutter/material.dart';
import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:provider/provider.dart';
class AutoCompleteField extends StatefulWidget { class AutoCompleteField extends StatefulWidget {
final String initialValue; final String initialValue;
final Function(String) onSearch; final Function(String) onSearch;
@ -21,7 +22,6 @@ class AutoCompleteField extends StatefulWidget {
} }
class _AutoCompleteFieldState extends State<AutoCompleteField> { class _AutoCompleteFieldState extends State<AutoCompleteField> {
SettingProvider _settingProvider; SettingProvider _settingProvider;
TextEditingController _controller; TextEditingController _controller;
@ -36,29 +36,26 @@ class _AutoCompleteFieldState extends State<AutoCompleteField> {
_controller.dispose(); _controller.dispose();
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_settingProvider = Provider.of<SettingProvider>(context); _settingProvider = Provider.of<SettingProvider>(context);
Subtitle _subtitle = AppLocalization.of(context).subtitle; Subtitle _subtitle = AppLocalization.of(context).subtitle;
return Container( return Container(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(horizontal: 16),
horizontal: 16
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: AColors.inputFieldBackgroundColor,
border: Border.all(color:AColors.black), border: Border.all(
color: Color(0xffefefef),
borderRadius: BorderRadius.circular( ),
AppStyle.borderRadius * AppStyle.getScaleFactor(context) borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
), // boxShadow: [
boxShadow: [ // AppStyle.boxShadow
AppStyle.boxShadow // ]
]
), ),
child: TypeAheadField<Hospital>( child: TypeAheadField<Hospital>(
textFieldConfiguration: TextFieldConfiguration( textFieldConfiguration: TextFieldConfiguration(
style: Theme.of(context).textTheme.headline6, style: Theme.of(context).textTheme.headline6,
onSubmitted: widget.onSave, onSubmitted: widget.onSave,
controller: _controller, controller: _controller,
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -70,15 +67,11 @@ class _AutoCompleteFieldState extends State<AutoCompleteField> {
enabledBorder: InputBorder.none, enabledBorder: InputBorder.none,
), ),
textInputAction: TextInputAction.search, textInputAction: TextInputAction.search,
onEditingComplete:(){ onEditingComplete: () {
widget.onSearch(_controller.text); widget.onSearch(_controller.text);
} }),
),
suggestionsCallback: (vale) async { suggestionsCallback: (vale) async {
return await HospitalsProvider().getHospitalsList( return await HospitalsProvider().getHospitalsList(host: _settingProvider.host, title: vale);
host: _settingProvider.host,
title: vale
);
}, },
itemBuilder: (context, hospital) { itemBuilder: (context, hospital) {
return HospitalItem( return HospitalItem(

@ -1,65 +1,48 @@
import 'package:flutter/material.dart';
import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/models/hospital.dart'; import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/hospitals/single_hospital_picker.dart'; import 'package:test_sa/views/widgets/hospitals/single_hospital_picker.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class HospitalButton extends StatelessWidget { class HospitalButton extends StatelessWidget {
final Function(Hospital) onHospitalPick; final Function(Hospital) onHospitalPick;
final Hospital hospital; final Hospital hospital;
const HospitalButton({ const HospitalButton({Key key, this.hospital, this.onHospitalPick}) : super(key: key);
Key key,
this.hospital,
this.onHospitalPick
}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Subtitle _subtitle = AppLocalization.of(context).subtitle; Subtitle _subtitle = AppLocalization.of(context).subtitle;
return ElevatedButton( return ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
foregroundColor: AColors.primaryColor, elevation: 0,
backgroundColor: AColors.white, foregroundColor: AColors.primaryColor,
padding: EdgeInsets.symmetric(horizontal: 16,vertical: 12), backgroundColor: AColors.inputFieldBackgroundColor,
shape: RoundedRectangleBorder( padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8),
borderRadius: BorderRadius.circular( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context))),
AppStyle.borderRadius * AppStyle.getScaleFactor(context)
),
side: const BorderSide(
color: AColors.black
)
), ),
),
child: Row( child: Row(
children: [ children: [
const FaIcon(
FontAwesomeIcons.solidHospital,
size: 28,
color: AColors.black,
),
Expanded( Expanded(
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 6), padding: const EdgeInsets.symmetric(horizontal: 8),
child: Text( child: Text(
hospital?.name ?? _subtitle.pickHospital, hospital?.name ?? _subtitle.pickHospital,
style: Theme.of(context).textTheme.subtitle1, style: Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 14, color: AColors.grey3A),
textScaleFactor: AppStyle.getScaleFactor(context), // textScaleFactor: AppStyle.getScaleFactor(context),
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
textAlign: TextAlign.center, textAlign: TextAlign.left,
), ),
), ),
), ),
const Icon(Icons.keyboard_arrow_down, size: 28, color: AColors.grey3A),
], ],
), ),
onPressed: () async { onPressed: () async {
Hospital _hospital = await Navigator.of(context).pushNamed(SingleHospitalPicker.id) as Hospital; Hospital _hospital = await Navigator.of(context).pushNamed(SingleHospitalPicker.id) as Hospital;
onHospitalPick(_hospital); onHospitalPick(_hospital);
} });
);
} }
} }

@ -1,160 +1,170 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:image_picker/image_picker.dart';
import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/buttons/app_flat_button.dart'; import 'package:test_sa/views/widgets/buttons/app_flat_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:image_picker/image_picker.dart';
import 'multi_image_picker_item.dart'; import 'multi_image_picker_item.dart';
class MultiImagesPicker extends StatefulWidget { class MultiImagesPicker extends StatefulWidget {
final String label; final String label;
final bool error; final bool error;
final List<File> images; final List<File> images;
const MultiImagesPicker({Key key, this.images, this.label, this.error = false}) : super(key: key); const MultiImagesPicker({Key key, this.images, this.label, this.error = false}) : super(key: key);
@override @override
_MultiImagesPickerState createState() => _MultiImagesPickerState(); _MultiImagesPickerState createState() => _MultiImagesPickerState();
} }
class _MultiImagesPickerState extends State<MultiImagesPicker> class _MultiImagesPickerState extends State<MultiImagesPicker> with TickerProviderStateMixin {
with TickerProviderStateMixin{
Size _size; Size _size;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_size = MediaQuery.of(context).size; _size = MediaQuery.of(context).size;
Subtitle _subtitle = AppLocalization.of(context).subtitle; Subtitle _subtitle = AppLocalization.of(context).subtitle;
return Column( return Container(
crossAxisAlignment: CrossAxisAlignment.start, padding: EdgeInsets.all(12),
children: [ decoration: BoxDecoration(
SizedBox(height: 8 * AppStyle.getScaleFactor(context),), color: Color(0xfff5f5f5),
Row( border: Border.all(
children: [ color: Color(0xffefefef),
Expanded(
child: Text(
widget.label ?? _subtitle.images,
style: Theme.of(context).textTheme
.headline6.copyWith(fontSize: 18,),
textScaleFactor: AppStyle.getScaleFactor(context),
),
),
AFlatButton(
text: _subtitle.add,
onPressed: (){onImagePick(_subtitle);},
),
],
), ),
SizedBox(height: 8 * AppStyle.getScaleFactor(context),), borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
AnimatedSize( ),
duration: Duration(milliseconds: 400), child: Column(
child: !widget.error ? SizedBox.shrink() : crossAxisAlignment: CrossAxisAlignment.start,
Column( children: [
crossAxisAlignment: CrossAxisAlignment.start, // SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
Row(
children: [ children: [
Text( Expanded(
_subtitle.imagesRequired, child: Text(
style: Theme.of(context).textTheme.headline6.copyWith( widget.label ?? _subtitle.images,
fontSize: 14, style: Theme.of(context).textTheme.headline6.copyWith(
color: AColors.red, fontSize: 16,
),
textScaleFactor: AppStyle.getScaleFactor(context),
), ),
textScaleFactor: AppStyle.getScaleFactor(context),
), ),
SizedBox(height: 8 * AppStyle.getScaleFactor(context),), AFlatButton(
text: _subtitle.add,
onPressed: () {
onImagePick(_subtitle);
},
),
], ],
), ),
), 12.height,
AnimatedSwitcher( AnimatedSize(
duration: Duration(milliseconds: 400), duration: Duration(milliseconds: 400),
child: Container( child: !widget.error
key: ValueKey(widget.images.length), ? SizedBox.shrink()
width: _size.width, : Column(
height: 200 * AppStyle.getScaleFactor(context), crossAxisAlignment: CrossAxisAlignment.start,
padding: EdgeInsets.all(8 * AppStyle.getScaleFactor(context),), children: [
alignment: Alignment.topLeft, Text(
decoration: BoxDecoration( _subtitle.imagesRequired,
border: Border.all( style: Theme.of(context).textTheme.headline6.copyWith(
color: Theme.of(context).primaryColor, fontSize: 14,
width: 2 color: AColors.red,
),
textScaleFactor: AppStyle.getScaleFactor(context),
),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
],
),
),
AnimatedSwitcher(
duration: Duration(milliseconds: 400),
child: Container(
key: ValueKey(widget.images.length),
width: _size.width,
height: 200 * AppStyle.getScaleFactor(context),
padding: EdgeInsets.all(
8 * AppStyle.getScaleFactor(context),
), ),
borderRadius: BorderRadius.circular( alignment: Alignment.topLeft,
8 * AppStyle.getScaleFactor(context)), decoration: BoxDecoration(
), border: Border.all(color: Theme.of(context).primaryColor, width: 2),
child: widget.images.isEmpty? borderRadius: BorderRadius.circular(8 * AppStyle.getScaleFactor(context)),
MaterialButton( ),
onPressed: (){onImagePick(_subtitle);}, child: widget.images.isEmpty
child: Center( ? MaterialButton(
child: Icon( onPressed: () {
onImagePick(_subtitle);
},
child: Center(
child: Icon(
Icons.add_a_photo_outlined, Icons.add_a_photo_outlined,
size: 48 * AppStyle.getScaleFactor(context), size: 48 * AppStyle.getScaleFactor(context),
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
)),
) )
), : GridView.count(
) : crossAxisCount: 2,
GridView.count( //_size.width ~/ 80,
crossAxisCount: 2,//_size.width ~/ 80, scrollDirection: Axis.horizontal,
scrollDirection: Axis.horizontal, mainAxisSpacing: 10,
mainAxisSpacing: 10, crossAxisSpacing: 10,
crossAxisSpacing: 10, children: List.generate(widget.images.length, (index) {
children: List.generate( File _image = widget.images[index];
widget.images.length, return MultiImagesPickerItem(
(index) { image: _image,
File _image = widget.images[index]; onRemoveTap: (image) {
return MultiImagesPickerItem( widget.images.remove(image);
image: _image, setState(() {});
onRemoveTap: (image){ },
widget.images.remove(image); );
setState(() {}); }),
}, ),
);
}
),
), ),
), ),
), ],
], ),
); );
} }
onImagePick( Subtitle _subtitle) async {
if(widget.images.length >= 5){ onImagePick(Subtitle _subtitle) async {
if (widget.images.length >= 5) {
Fluttertoast.showToast(msg: _subtitle.maxImagesNumberIs5); Fluttertoast.showToast(msg: _subtitle.maxImagesNumberIs5);
return; return;
} }
ImageSource source = await showDialog( ImageSource source = await showDialog(
context: context, context: context,
builder: (dialogContext) => CupertinoAlertDialog( builder: (dialogContext) => CupertinoAlertDialog(
actions: <Widget>[ actions: <Widget>[
TextButton( TextButton(
child: Text(_subtitle.pickFromCamera), child: Text(_subtitle.pickFromCamera),
onPressed: () { onPressed: () {
Navigator.of(dialogContext).pop(ImageSource.camera); Navigator.of(dialogContext).pop(ImageSource.camera);
}, },
), ),
TextButton( TextButton(
child: Text(_subtitle.pickFromGallery), child: Text(_subtitle.pickFromGallery),
onPressed: () { onPressed: () {
Navigator.of(dialogContext).pop(ImageSource.gallery); Navigator.of(dialogContext).pop(ImageSource.gallery);
}, },
), ),
], ],
) ));
); if (source == null) return;
if(source == null)
return;
final pickedFile = await ImagePicker().pickImage( final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 800, maxHeight: 800);
source: source,
imageQuality: 70,
maxWidth: 800,
maxHeight: 800
);
if (pickedFile != null) { if (pickedFile != null) {
File _fileImage = File(pickedFile.path); File _fileImage = File(pickedFile.path);
if(_fileImage != null){ if (_fileImage != null) {
widget.images.insert(0, _fileImage); widget.images.insert(0, _fileImage);
setState(() {}); setState(() {});
} }

@ -1,7 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/app_style/sizing.dart';
class LandPageItem extends StatelessWidget {
class LandPageItem extends StatelessWidget {
final String text; final String text;
final IconData icon; final IconData icon;
final VoidCallback onPressed; final VoidCallback onPressed;
@ -10,28 +11,34 @@ class LandPageItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ElevatedButton( return InkWell(
style: ElevatedButton.styleFrom( onTap: onPressed,
padding: EdgeInsets.all(10 * AppStyle.getScaleFactor(context),), child: Container(
textStyle: Theme.of(context).textTheme.subtitle2, padding: const EdgeInsets.only(left: 20, right: 20, bottom: 15, top: 28),
shape: RoundedRectangleBorder( decoration: BoxDecoration(
borderRadius: BorderRadius.circular( color: Colors.white,
AppStyle.getBorderRadius(context) borderRadius: BorderRadius.circular(15),
) boxShadow: [
), BoxShadow(
//foregroundColor: Colors.white, color: const Color(0xff000000).withOpacity(.15),
blurRadius: 26,
offset: const Offset(0, -3),
),
],
), ),
onPressed: onPressed,
child: Column( child: Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
Expanded( mainAxisAlignment: MainAxisAlignment.spaceBetween,
child: Center( children: <Widget>[
child: Icon(icon,size: 58 * AppStyle.getScaleFactor(context),) Icon(
), icon,
color: AColors.primaryColor,
size: 42 * AppStyle.getScaleFactor(context),
), ),
Text(text,textAlign: TextAlign.center,), Text(text, style: TextStyle(color: AColors.grey3A)),
], ],
) ),
),
); );
} }
} }

@ -3,22 +3,22 @@ import 'package:flutter/services.dart';
import 'package:flutter_sound/flutter_sound.dart'; import 'package:flutter_sound/flutter_sound.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:rive/rive.dart'; import 'package:rive/rive.dart';
import 'package:test_sa/views/widgets/buttons/app_button.dart';
import 'package:test_sa/views/widgets/buttons/app_icon_button2.dart'; import 'package:test_sa/views/widgets/buttons/app_icon_button2.dart';
import 'package:test_sa/views/widgets/buttons/app_small_button.dart'; import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
import 'package:test_sa/views/widgets/sound/sound_player.dart'; import 'package:test_sa/views/widgets/sound/sound_player.dart';
import '../../app_style/sizing.dart'; import '../../app_style/sizing.dart';
class RecordSound extends StatefulWidget { class RecordSound extends StatefulWidget {
final Function(String) onRecord; final Function(String) onRecord;
const RecordSound({Key key,@required this.onRecord}) : super(key: key);
const RecordSound({Key key, @required this.onRecord}) : super(key: key);
@override @override
State<RecordSound> createState() => _RecordSoundState(); State<RecordSound> createState() => _RecordSoundState();
} }
class _RecordSoundState extends State<RecordSound> { class _RecordSoundState extends State<RecordSound> {
FlutterSoundRecorder _myRecorder = FlutterSoundRecorder(); FlutterSoundRecorder _myRecorder = FlutterSoundRecorder();
bool _recorderIsOpened = false; bool _recorderIsOpened = false;
bool _recording = false; bool _recording = false;
@ -28,8 +28,9 @@ class _RecordSoundState extends State<RecordSound> {
@override @override
void setState(VoidCallback fn) { void setState(VoidCallback fn) {
if(mounted) super.setState(fn); if (mounted) super.setState(fn);
} }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -41,7 +42,7 @@ class _RecordSoundState extends State<RecordSound> {
// Load the animation file from the bundle, note that you could also // Load the animation file from the bundle, note that you could also
// download this. The RiveFile just expects a list of bytes. // download this. The RiveFile just expects a list of bytes.
rootBundle.load('assets/rives/recording.riv').then( rootBundle.load('assets/rives/recording.riv').then(
(data) async { (data) async {
// Load the RiveFile from the binary data. // Load the RiveFile from the binary data.
final file = RiveFile.import(data); final file = RiveFile.import(data);
// The artboard is the root of the animation and gets drawn in the // The artboard is the root of the animation and gets drawn in the
@ -53,10 +54,8 @@ class _RecordSoundState extends State<RecordSound> {
_rive = artboard; _rive = artboard;
setState(() {}); setState(() {});
}, },
); );
} }
@override @override
@ -71,21 +70,16 @@ class _RecordSoundState extends State<RecordSound> {
_fastTab = false; _fastTab = false;
// await Permission.camera // await Permission.camera
PermissionStatus status = await Permission.microphone.request(); PermissionStatus status = await Permission.microphone.request();
if(!status.isGranted){ if (!status.isGranted) {
return; return;
} }
_rive.addController(SimpleAnimation('recording')); _rive.addController(SimpleAnimation('recording'));
if(!_recorderIsOpened){ if (!_recorderIsOpened) {
await _myRecorder.openRecorder(); await _myRecorder.openRecorder();
_recorderIsOpened = true; _recorderIsOpened = true;
} }
await _myRecorder.startRecorder( await _myRecorder.startRecorder(toFile: "record_${DateTime.now().millisecondsSinceEpoch}.mp4", codec: Codec.aacMP4, sampleRate: 360000, bitRate: 360000);
toFile: "record_${DateTime.now().millisecondsSinceEpoch}.mp4",
codec: Codec.aacMP4,
sampleRate: 360000,
bitRate: 360000
);
_recording = true; _recording = true;
setState(() {}); setState(() {});
@ -93,7 +87,7 @@ class _RecordSoundState extends State<RecordSound> {
} }
_stopRecording() async { _stopRecording() async {
if(!_recording){ if (!_recording) {
_fastTab = true; _fastTab = true;
setState(() {}); setState(() {});
return; return;
@ -103,12 +97,12 @@ class _RecordSoundState extends State<RecordSound> {
_record = path; _record = path;
widget.onRecord(path); widget.onRecord(path);
_recording = false; _recording = false;
setState(() { }); setState(() {});
print("onTapUp"); print("onTapUp");
} }
_cancelRecording() async { _cancelRecording() async {
if(!_recording) return; if (!_recording) return;
String path = await _myRecorder.stopRecorder(); String path = await _myRecorder.stopRecorder();
_myRecorder.deleteRecord(fileName: path); _myRecorder.deleteRecord(fileName: path);
_rive.addController(SimpleAnimation('delete')); _rive.addController(SimpleAnimation('delete'));
@ -116,86 +110,98 @@ class _RecordSoundState extends State<RecordSound> {
// rebuild(); // rebuild();
_recording = false; _recording = false;
await Future.delayed(const Duration(seconds: 1)); await Future.delayed(const Duration(seconds: 1));
if(!_recording) setState(() { }); if (!_recording) setState(() {});
print("onTapCancel"); print("onTapCancel");
// _message.memoryAudio.; // _message.memoryAudio.;
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Container(
children: [ padding: EdgeInsets.only(left: 12, right: 0),
Row( decoration: BoxDecoration(
children: [ color: Color(0xfff5f5f5),
Expanded( border: Border.all(
child: _recording ? color: Color(0xffefefef),
Row( ),
children: [ borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
ASmallButton( ),
text: "done", child: Column(
onPressed: (){ children: [
_stopRecording(); Row(
}, children: [
), Expanded(
Expanded( child: _recording
child: Stack( ? Row(
children: [ children: [
SizedBox( ASmallButton(
height: 24 * AppStyle.getScaleFactor(context), text: "done",
child: Rive(artboard: _rive,) onPressed: () {
), _stopRecording();
InkWell( },
child: SizedBox(
height: 32 * AppStyle.getScaleFactor(context),
width: MediaQuery.of(context).size.width,
), ),
onTap: (){ Expanded(
_cancelRecording(); child: Stack(
}, children: [
), SizedBox(
], height: 24 * AppStyle.getScaleFactor(context),
), child: Rive(
), artboard: _rive,
], )),
): _record != null InkWell(
? Row( child: SizedBox(
children: [ height: 32 * AppStyle.getScaleFactor(context),
Expanded(child: ASoundPlayer(audio: _record)), width: MediaQuery.of(context).size.width,
AIconButton2( ),
iconData: Icons.delete, onTap: () {
onPressed: (){ _cancelRecording();
widget.onRecord(null); },
_record = null; ),
setState(() { }); ],
}, ),
),
],
) )
], : _record != null
) ? Row(
: const Text("Record Voice"), children: [
), Expanded(child: ASoundPlayer(audio: _record)),
Material( AIconButton2(
color: Colors.transparent, iconData: Icons.delete,
child: GestureDetector( onPressed: () {
//key: ValueKey("voice"), widget.onRecord(null);
child: const Padding( _record = null;
padding: EdgeInsets.all(16.0), setState(() {});
child: Icon(Icons.mic), },
), )
],
)
: const Text("Record Voice"),
),
Material(
color: Colors.transparent,
child: GestureDetector(
//key: ValueKey("voice"),
child: const Padding(
padding: EdgeInsets.all(12.0),
child: Icon(Icons.mic),
),
onTapDown: (TapDownDetails details) async { onTapDown: (TapDownDetails details) async {
_startRecording(); _startRecording();
}, },
onTapUp: (TapUpDetails details) async { onTapUp: (TapUpDetails details) async {
_stopRecording(); _stopRecording();
}, },
onTapCancel: () async { onTapCancel: () async {
_cancelRecording(); _cancelRecording();
}, },
),
), ),
), ],
], ),
), ],
], ),
); );
} }
} }

@ -1,22 +1,19 @@
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/views/widgets/buttons/app_icon_button.dart';
import 'package:test_sa/views/widgets/buttons/app_icon_button2.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_recognition_error.dart';
import 'package:speech_to_text/speech_recognition_result.dart'; import 'package:speech_to_text/speech_recognition_result.dart';
import 'package:speech_to_text/speech_to_text.dart'; import 'package:speech_to_text/speech_to_text.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/buttons/app_icon_button2.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../app_text_form_field.dart';
class SpeechToTextButton extends StatefulWidget { class SpeechToTextButton extends StatefulWidget {
final TextEditingController controller; final TextEditingController controller;
final bool mini; final bool mini;
const SpeechToTextButton({
Key key, this.controller,this.mini = false const SpeechToTextButton({Key key, this.controller, this.mini = false}) : super(key: key);
}) : super(key: key);
@override @override
_SpeechToTextButtonState createState() => _SpeechToTextButtonState(); _SpeechToTextButtonState createState() => _SpeechToTextButtonState();
@ -32,7 +29,7 @@ class _SpeechToTextButtonState extends State<SpeechToTextButton> {
_speechEnabled = await _speechToText.initialize( _speechEnabled = await _speechToText.initialize(
onError: (SpeechRecognitionError error) async { onError: (SpeechRecognitionError error) async {
Fluttertoast.showToast(msg: "failed to convert text to speech"); Fluttertoast.showToast(msg: "failed to convert text to speech");
setState(() { }); setState(() {});
}, },
); );
} }
@ -40,18 +37,17 @@ class _SpeechToTextButtonState extends State<SpeechToTextButton> {
/// Each time to start a speech recognition session /// Each time to start a speech recognition session
void _startListening() async { void _startListening() async {
_speechEnabled = _speechToText.isAvailable; _speechEnabled = _speechToText.isAvailable;
if(_speechToText.isListening){ if (_speechToText.isListening) {
Fluttertoast.showToast(msg: "Currently in use"); Fluttertoast.showToast(msg: "Currently in use");
return; return;
} }
if(!_speechEnabled) return; if (!_speechEnabled) return;
await _speechToText.listen( await _speechToText.listen(
onResult: (SpeechRecognitionResult result){ onResult: (SpeechRecognitionResult result) {
widget.controller.text = result.recognizedWords; widget.controller.text = result.recognizedWords;
setState(() {}); setState(() {});
}, },
localeId: _settingProvider.speechToText localeId: _settingProvider.speechToText);
);
setState(() {}); setState(() {});
} }
@ -72,51 +68,66 @@ class _SpeechToTextButtonState extends State<SpeechToTextButton> {
@override @override
void setState(VoidCallback fn) { void setState(VoidCallback fn) {
if(!this.mounted) return; if (!this.mounted) return;
super.setState(fn); super.setState(fn);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_settingProvider = Provider.of<SettingProvider>(context); _settingProvider = Provider.of<SettingProvider>(context);
return Row( return Container(
children: [ padding: EdgeInsets.only(left: 12, right: 12),
widget.mini ? SizedBox.shrink() : decoration: BoxDecoration(
ASubTitle("Text To Speech"), color: Color(0xfff5f5f5),
widget.controller.text.isNotEmpty? border: Border.all(
AIconButton2( color: Color(0xffefefef),
iconData: Icons.delete,
onPressed: (){
widget.controller.clear();
setState(() {});
},
):SizedBox.shrink(),
Spacer(),
TextButton(
onPressed: (){
if(_speechToText.isListening) return;
if(_settingProvider.speechToText == "ar"){
_settingProvider.setSpeechToText("en");
} else{
_settingProvider.setSpeechToText("ar");
}
},
child: Text(_settingProvider.speechToText)
), ),
GestureDetector( borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
child: _speechToText.isListening ),
? Icon(Icons.fiber_manual_record,color: Colors.red,) child: Row(
: Icon(Icons.mic,color: Theme.of(context).colorScheme.primary,), children: [
widget.mini ? SizedBox.shrink() : ASubTitle("Text To Speech"),
widget.controller.text.isNotEmpty
? AIconButton2(
iconData: Icons.delete,
onPressed: () {
widget.controller.clear();
setState(() {});
},
)
: SizedBox.shrink(),
Spacer(),
TextButton(
onPressed: () {
if (_speechToText.isListening) return;
onTap: () async { if (_settingProvider.speechToText == "ar") {
if(!_speechEnabled){ _settingProvider.setSpeechToText("en");
Fluttertoast.showToast(msg: "microphone not available"); } else {
return; _settingProvider.setSpeechToText("ar");
} }
_startListening(); },
}, child: Text(_settingProvider.speechToText)),
), GestureDetector(
], child: _speechToText.isListening
? Icon(
Icons.fiber_manual_record,
color: Colors.red,
)
: Icon(
Icons.mic,
color: Theme.of(context).colorScheme.primary,
),
onTap: () async {
if (!_speechEnabled) {
Fluttertoast.showToast(msg: "microphone not available");
return;
}
_startListening();
},
),
],
),
); );
} }
} }

@ -1,28 +1,28 @@
import 'package:flutter/material.dart';
import 'package:test_sa/models/status.dart'; import 'package:test_sa/models/status.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/app_style/sizing.dart';
import 'package:flutter/material.dart';
class SingleStatusMenu extends StatefulWidget { class SingleStatusMenu extends StatefulWidget {
final List<Status> statuses; final List<Status> statuses;
final Status initialStatus; final Status initialStatus;
final Function(Status) onSelect; final Function(Status) onSelect;
const SingleStatusMenu({Key key, this.statuses, this.onSelect, this.initialStatus}) : super(key: key); const SingleStatusMenu({Key key, this.statuses, this.onSelect, this.initialStatus}) : super(key: key);
@override @override
_SingleStatusMenuState createState() => _SingleStatusMenuState(); _SingleStatusMenuState createState() => _SingleStatusMenuState();
} }
class _SingleStatusMenuState extends State<SingleStatusMenu> { class _SingleStatusMenuState extends State<SingleStatusMenu> {
Status _selectedStatus; Status _selectedStatus;
@override @override
void didUpdateWidget(covariant SingleStatusMenu oldWidget) { void didUpdateWidget(covariant SingleStatusMenu oldWidget) {
if(widget.initialStatus != null){ if (widget.initialStatus != null) {
_selectedStatus = widget.statuses?.firstWhere( _selectedStatus = widget.statuses?.firstWhere((element) {
(element) { return element?.id == widget.initialStatus.id;
return element?.id == widget.initialStatus.id; });
});
} else { } else {
_selectedStatus = null; _selectedStatus = null;
} }
@ -31,43 +31,40 @@ class _SingleStatusMenuState extends State<SingleStatusMenu> {
@override @override
void initState() { void initState() {
if(widget.initialStatus != null){ if (widget.initialStatus != null) {
_selectedStatus = widget.statuses?.firstWhere( _selectedStatus = widget.statuses?.firstWhere((element) {
(element) { return element?.id == widget.initialStatus.id;
return element?.id == widget.initialStatus.id; });
});
} }
super.initState(); super.initState();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(horizontal: 16),
horizontal: 16
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: AColors.inputFieldBackgroundColor,
border: Border.all(color:AColors.black), border: Border.all(
borderRadius: BorderRadius.circular( color: Color(0xffefefef),
AppStyle.borderRadius * AppStyle.getScaleFactor(context) ),
), borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
boxShadow: const [ // boxShadow: const [
AppStyle.boxShadow // AppStyle.boxShadow
] // ]
), ),
child: DropdownButton<Status>( child: DropdownButton<Status>(
value: _selectedStatus, value: _selectedStatus,
iconSize: 24, iconSize: 24,
elevation: 16, icon: Icon(Icons.keyboard_arrow_down_rounded),
elevation: 0,
isExpanded: true, isExpanded: true,
hint: Text( hint: Text(
"Select", "Select",
style: Theme.of(context).textTheme.subtitle1, style: Theme.of(context).textTheme.subtitle1,
), ),
style: TextStyle( style: TextStyle(color: Theme.of(context).primaryColor),
color: Theme.of(context).primaryColor
),
underline: SizedBox.shrink(), underline: SizedBox.shrink(),
onChanged: (Status newValue) { onChanged: (Status newValue) {
setState(() { setState(() {
@ -75,21 +72,15 @@ class _SingleStatusMenuState extends State<SingleStatusMenu> {
}); });
widget.onSelect(newValue); widget.onSelect(newValue);
}, },
items: widget.statuses items: widget.statuses.map<DropdownMenuItem<Status>>((Status value) {
.map<DropdownMenuItem<Status>>((Status value) {
return DropdownMenuItem<Status>( return DropdownMenuItem<Status>(
value: value, value: value,
child: Text( child: Text(
value.label, value.label,
style: Theme.of(context).textTheme.subtitle1.copyWith( style: Theme.of(context).textTheme.subtitle1.copyWith(color: Theme.of(context).primaryColor, fontWeight: FontWeight.w600),
color: Theme.of(context).primaryColor,
fontSize: 11,
//fontWeight: FontWeight.bold
),
), ),
); );
}) }).toList(),
.toList(),
), ),
); );
} }

@ -12,7 +12,7 @@ class ASubTitle extends StatelessWidget {
padding: padding ?? EdgeInsets.zero, padding: padding ?? EdgeInsets.zero,
child: Text( child: Text(
text, text,
style: Theme.of(context).textTheme.subtitle2.copyWith( style: Theme.of(context).textTheme.bodyText1.copyWith(
// fontWeight: FontWeight.bold, // fontWeight: FontWeight.bold,
fontSize: font, fontSize: font,
color: color color: color

@ -92,7 +92,7 @@ flutter:
- assets/subtitles/ - assets/subtitles/
- assets/rives/ - assets/rives/
fonts: fonts:
- family: Swiss - family: Swiss
fonts: fonts:
- asset: assets/fonts/Gotham_Rounded_Light.otf - asset: assets/fonts/Gotham_Rounded_Light.otf
weight: 300 weight: 300
@ -100,3 +100,23 @@ flutter:
weight: 400 weight: 400
- asset: assets/fonts/Gotham_Rounded_Bold.otf - asset: assets/fonts/Gotham_Rounded_Bold.otf
weight: 700 weight: 700
- family: Poppins
fonts:
- asset: assets/fonts/poppins/Poppins-Black.ttf
weight: 900
- asset: assets/fonts/poppins/Poppins-ExtraBold.ttf
weight: 800
- asset: assets/fonts/poppins/Poppins-Bold.ttf
weight: 700
- asset: assets/fonts/poppins/Poppins-SemiBold.ttf
weight: 600
- asset: assets/fonts/poppins/Poppins-Medium.ttf
weight: 500
- asset: assets/fonts/poppins/Poppins-Regular.ttf
weight: 400
- asset: assets/fonts/poppins/Poppins-Light.ttf
weight: 300
- asset: assets/fonts/poppins/Poppins-ExtraLight.ttf
weight: 200
- asset: assets/fonts/poppins/Poppins-Thin.ttf
weight: 100
Loading…
Cancel
Save