Profile Page and Back Button Click

merge-requests/439/merge
Mirza.Shafique 3 years ago
parent 6261f01ab6
commit d664a216c6

@ -1497,4 +1497,6 @@ const Map localizedValues = {
"years": {"en": "Years", "ar": "سنوات"},
"respirationBPM": { "en": "bpm", "ar": "نفس" },
"extremeObese": {"en": "Extreme Obese", "ar": "السمنة المفرطة"},
"selectLanguage": { "en": "Please select any language:", "ar": ":الرجاء تحديد أي لغة" },
"recAlert": { "en": "How do you want to receive alerts?", "ar": "كيف تريد تلقي التنبيهات؟" },
};

@ -102,13 +102,18 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
LocationUtils locationUtils;
Future<bool> onWillPop() {
DateTime now = DateTime.now();
if (currentBackPressTime == null || now.difference(currentBackPressTime) > Duration(seconds: 2)) {
currentBackPressTime = now;
AppToast.showToast(message: TranslationBase.of(context).pressAgain);
if (currentTab != 0) {
changeCurrentTab(0);
return Future.value(false);
} else {
DateTime now = DateTime.now();
if (currentBackPressTime == null || now.difference(currentBackPressTime) > Duration(seconds: 2)) {
currentBackPressTime = now;
AppToast.showToast(message: TranslationBase.of(context).pressAgain);
return Future.value(false);
}
return Future.value(true);
}
return Future.value(true);
}
changeCurrentTab(int tab) {

@ -50,17 +50,20 @@ class _VitalSingChartAndDetialsState extends State<VitalSingChartAndDetials> {
return SingleChildScrollView(
child: Column(
children: <Widget>[
Card(
shape: cardRadius(12),
elevation: 1,
margin: EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 8),
// child: ShowChart(
// title: widget.name,
// timeSeries: timeSeriesData,
// indexes: timeSeriesData.length ~/ 5.5,
// horizontalInterval: 8,
// ),
child: SyncFuChart(),
Container(
height: 400,
child: Card(
shape: cardRadius(12),
elevation: 1,
margin: EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 8),
child: ShowChart(
title: widget.name,
timeSeries: timeSeriesData,
indexes: timeSeriesData.length ~/ 5.5,
horizontalInterval: 8,
),
// child: SyncFuChart(),
),
),
Card(
shape: cardRadius(12),

@ -2,9 +2,11 @@ import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
import 'package:flutter/cupertino.dart';
@ -16,8 +18,7 @@ class ProfileSettings extends StatefulWidget {
_ProfileSettings createState() => _ProfileSettings();
}
class _ProfileSettings extends State<ProfileSettings>
with TickerProviderStateMixin {
class _ProfileSettings extends State<ProfileSettings> with TickerProviderStateMixin {
bool smsAlert = true;
bool emailAlert = true;
int language = 1;
@ -25,6 +26,7 @@ class _ProfileSettings extends State<ProfileSettings>
TextEditingController emergencyContact = new TextEditingController();
TextEditingController emailController = new TextEditingController();
TextEditingController emergencyContactName = new TextEditingController();
@override
void initState() {
Future.delayed(new Duration(seconds: 0), () {
@ -37,199 +39,300 @@ class _ProfileSettings extends State<ProfileSettings>
Widget build(BuildContext context) {
return BaseView<DashboardViewModel>(
onModelReady: (model) => {},
builder: (_, model, wi) => Container(
child: model.user != null
? ListView(scrollDirection: Axis.vertical, children: <Widget>[
Container(
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.all(15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
AppText(
TranslationBase.of(context).fileNo,
color: Colors.black,
),
AppText(
model.user.patientID.toString(),
color: Colors.black,
),
],
onModelReady: (model) => {},
builder: (_, model, wi) => Container(
child: model.user != null
? Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Card(
shape: cardRadius(8),
margin: EdgeInsets.zero,
elevation: 3,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
TranslationBase.of(context).fileNo + ": ",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.64,
),
),
Text(
model.user.patientID.toString(),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.64,
),
),
],
),
),
),
mHeight(12),
Text(
TranslationBase.of(context).languageSetting,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.64,
),
),
Text(
TranslationBase.of(context).selectLanguage,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
),
),
Row(
children: [
Expanded(
child: Row(
children: [
new Radio(
value: 2,
groupValue: language,
onChanged: (value) {
setState(() {
language = value;
});
},
),
Text(
TranslationBase.of(context).english,
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
),
),
],
),
),
Expanded(
child: Row(
children: [
Radio(
value: 1,
groupValue: language,
onChanged: (value) {
setState(() {
language = value;
});
},
),
Text(
TranslationBase.of(context).arabic,
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
),
),
],
),
),
],
),
mHeight(12),
Text(
TranslationBase.of(context).alert,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.64,
),
),
Text(
TranslationBase.of(context).recAlert,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
letterSpacing: -0.48,
),
),
Row(
children: [
Checkbox(
value: emailAlert,
onChanged: (value) {
setState(() {
emailAlert = value;
});
},
activeColor: CustomColors.accentColor,
),
Text(
TranslationBase.of(context).emailAlert,
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
),
),
],
),
Row(
children: [
Checkbox(
value: smsAlert,
onChanged: (value) {
setState(() {
smsAlert = value;
});
},
activeColor: CustomColors.accentColor,
),
Text(
TranslationBase.of(context).smsAlert,
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
),
),
],
),
mHeight(16),
Text(
TranslationBase.of(context).contactInfo,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.64,
),
),
mHeight(12),
inputWidget(TranslationBase.of(context).email, "", emailController),
mHeight(8),
inputWidget(TranslationBase.of(context).emergencyName, "", emergencyContactName),
mHeight(8),
inputWidget(TranslationBase.of(context).emergencyContact, "", emergencyContact),
mHeight(8),
],
),
),
),
SizedBox(
height: 1,
width: MediaQuery.of(context).size.width,
child: Container(
color: Colors.grey[300],
),
Container(
width: double.infinity,
child: Card(
margin: EdgeInsets.zero,
elevation: 20,
child: Padding(
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 16),
child: DefaultButton(
TranslationBase.of(context).save,
() {
saveSettings();
},
),
),
),
Padding(
child: AppText(
TranslationBase.of(context).languageSetting,
fontWeight: FontWeight.bold),
padding: EdgeInsets.all(10),
),
],
)
: Center(
child: AppText(TranslationBase.of(context).loginToUseService),
),
),
);
}
Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) {
return Container(
padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.white,
border: Border.all(
color: Color(0xffefefef),
width: 1,
),
),
child: InkWell(
onTap: hasSelection ? () {} : null,
child: Row(
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_labelText,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: Color(0xff2B353E),
letterSpacing: -0.44,
),
Container(
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
AppText(TranslationBase.of(context).english),
new Radio(
value: 2,
groupValue: language,
onChanged: (value) {
setState(() {
language = value;
});
},
)
],
)),
Container(
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
AppText(TranslationBase.of(context).arabic),
new Radio(
value: 1,
groupValue: language,
onChanged: (value) {
setState(() {
language = value;
});
},
)
],
)),
Padding(
child: AppText(TranslationBase.of(context).alert),
padding: EdgeInsets.all(10),
),
TextField(
enabled: isEnable,
scrollPadding: EdgeInsets.zero,
keyboardType: TextInputType.number,
controller: _controller,
// onChanged: (value) => {validateForm()},
style: TextStyle(
fontSize: 14,
height: 21 / 14,
fontWeight: FontWeight.w400,
color: Color(0xff2B353E),
letterSpacing: -0.44,
),
Container(
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
AppText(TranslationBase.of(context).emailAlert),
Switch(
value: emailAlert,
onChanged: (value) {
setState(() {
emailAlert = value;
});
},
activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green,
)
],
)),
Container(
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
AppText(TranslationBase.of(context).smsAlert),
Switch(
value: smsAlert,
onChanged: (value) {
setState(() {
smsAlert = value;
});
},
activeTrackColor: Colors.lightGreenAccent,
activeColor: Colors.green,
)
],
)),
Padding(
child: AppText(TranslationBase.of(context).contactInfo),
padding: EdgeInsets.all(10),
),
Container(
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(TranslationBase.of(context).email),
TextField(
controller: emailController,
decoration: InputDecoration(
suffixIcon: Icon(Icons.edit),
))
],
)),
Container(
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(TranslationBase.of(context).emergencyName),
TextField(
controller: emergencyContactName,
decoration: InputDecoration(
suffixIcon: Icon(Icons.edit),
))
],
)),
Container(
color: Theme.of(context).textTheme.headline2.color,
padding: EdgeInsets.only(
top: 0, left: 10, right: 10, bottom: 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(
TranslationBase.of(context).emergencyContact),
TextField(
controller: emergencyContact,
decoration: InputDecoration(
suffixIcon: Icon(Icons.edit),
decoration: InputDecoration(
isDense: true,
hintText: _hintText,
hintStyle: TextStyle(
fontSize: 14,
height: 21 / 14,
fontWeight: FontWeight.w400,
color: Color(0xff575757),
letterSpacing: -0.56,
),
prefixIconConstraints: BoxConstraints(minWidth: 50),
prefixIcon: prefix == null
? null
: Text(
"+" + prefix,
style: TextStyle(
fontSize: 14,
height: 21 / 14,
fontWeight: FontWeight.w500,
color: Color(0xff2E303A),
letterSpacing: -0.56,
),
)
],
)),
Container(
padding: EdgeInsets.all(10),
child: Row(
children: <Widget>[
Expanded(
child: DefaultButton(
TranslationBase.of(context).save,
() {
saveSettings();
},
)),
],
))
])
: Center(
child:
AppText(TranslationBase.of(context).loginToUseService),
)));
),
contentPadding: EdgeInsets.zero,
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
),
),
],
),
),
if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined),
],
),
),
);
}
getSettings(context) {
GifLoaderDialogUtils.showMyDialog(context);
authService.getSettings().then((result) => {
GifLoaderDialogUtils.hideDialog(context),
setValue(result["PateintInfoForUpdateList"][0])
});
authService.getSettings().then((result) => {GifLoaderDialogUtils.hideDialog(context), setValue(result["PateintInfoForUpdateList"][0])});
}
setValue(value) {
@ -252,10 +355,6 @@ class _ProfileSettings extends State<ProfileSettings>
request["IsEmailAlertRequired"] = this.emailAlert;
request["IsSMSAlertRequired"] = this.smsAlert;
request["PreferredLanguage"] = this.language.toString();
authService.saveSettings(request).then((result) => {
AppToast.showSuccessToast(
message: TranslationBase.of(context).profileUpdate),
GifLoaderDialogUtils.hideDialog(context)
});
authService.saveSettings(request).then((result) => {AppToast.showSuccessToast(message: TranslationBase.of(context).profileUpdate), GifLoaderDialogUtils.hideDialog(context)});
}
}

@ -1,7 +1,9 @@
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/pages/settings/general_setting.dart';
import 'package:diplomaticquarterapp/pages/settings/profile_setting.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/others/arrow_back.dart';
import 'package:flutter/material.dart';
@ -9,6 +11,7 @@ class Settings extends StatefulWidget {
final int type;
Settings({this.type = 0});
@override
_Settings createState() => _Settings();
}
@ -18,8 +21,7 @@ class _Settings extends State<Settings> with TickerProviderStateMixin {
@override
void initState() {
_tabController =
new TabController(length: 2, vsync: this, initialIndex: widget.type);
_tabController = new TabController(length: 2, vsync: this, initialIndex: widget.type);
if (widget.type == 1) {
_tabController.animateTo(1);
@ -31,45 +33,45 @@ class _Settings extends State<Settings> with TickerProviderStateMixin {
@override
Widget build(BuildContext context) {
AppGlobal.context = context;
return Scaffold(
appBar: AppBar(
actions: [
IconButton(
icon: Icon(Icons.info, color: Colors.white),
onPressed: () {
//openInfoPage()
},
)
],
bottom: TabBar(
// isScrollable: true,
return AppScaffold(
isShowAppBar: false,
isShowDecPage: false,
showNewAppBarTitle: true,
showNewAppBar: true,
appBarTitle: TranslationBase.of(context).settings,
backgroundColor: Color(0xFFF7F7F7),
body: Column(
children: [
TabBar(
// isScrollable: true,
indicatorWeight: 5.0,
//indicatorSize: TabBarIndicatorSize.label,
// indicatorSize: TabBarIndicatorSize.tab,
indicatorWeight: 3.0,
//indicatorSize: TabBarIndicatorSize.label,
// indicatorSize: TabBarIndicatorSize.tab,
indicatorColor: Theme.of(context).primaryColor,
// labelColor: Theme.of(context).primaryColor,
tabs: [
Tab(text: TranslationBase.of(context).general),
Tab(
text: TranslationBase.of(context).profile,
)
],
controller: _tabController,
),
title: Text(TranslationBase.of(context).settings,
style: TextStyle(color: Colors.white)),
leading: Builder(
builder: (BuildContext context) {
return ArrowBack();
},
),
indicatorColor: CustomColors.accentColor,
labelColor: Colors.black,
unselectedLabelColor: CustomColors.grey,
// labelColor: Theme.of(context).primaryColor,
tabs: [
Tab(text: TranslationBase.of(context).general),
Tab(
text: TranslationBase.of(context).profile,
)
],
controller: _tabController,
),
Expanded(
child: TabBarView(
physics: NeverScrollableScrollPhysics(),
children: [
GeneralSettings(),
ProfileSettings(),
],
controller: _tabController),
),
],
),
body: TabBarView(
physics: NeverScrollableScrollPhysics(),
children: [GeneralSettings(), ProfileSettings()],
controller: _tabController),
);
}
}

@ -2361,6 +2361,9 @@ class TranslationBase {
String get selectSlot => localizedValues["selectSlot"][locale.languageCode];
String get selectLanguage => localizedValues["selectLanguage"][locale.languageCode];
String get recAlert => localizedValues["recAlert"][locale.languageCode];
}
class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> {

@ -1,69 +1,52 @@
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
import 'package:syncfusion_flutter_charts/sparkcharts.dart';
class SyncFuChart extends StatelessWidget {
List<_SalesData> data = [
_SalesData('Jan', 35),
_SalesData('Feb', 28),
_SalesData('Mar', 34),
_SalesData('Apr', 32),
_SalesData('May', 40),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Syncfusion Flutter chart'),
),
body: Column(
children: [
//Initialize the chart widget
SfCartesianChart(
primaryXAxis: CategoryAxis(),
// Chart title
title: ChartTitle(text: 'Half yearly sales analysis'),
// Enable legend
legend: Legend(isVisible: true),
// Enable tooltip
tooltipBehavior: TooltipBehavior(enable: true),
series: <ChartSeries<_SalesData, String>>[
LineSeries<_SalesData, String>(
dataSource: data,
xValueMapper: (_SalesData sales, _) => sales.year,
yValueMapper: (_SalesData sales, _) => sales.sales,
name: 'Sales',
// Enable data label
dataLabelSettings: DataLabelSettings(isVisible: true))
]),
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
//Initialize the spark charts widget
child: SfSparkLineChart.custom(
//Enable the trackball
trackball: SparkChartTrackball(activationMode: SparkChartActivationMode.tap),
//Enable marker
marker: SparkChartMarker(displayMode: SparkChartMarkerDisplayMode.all),
//Enable data label
labelDisplayMode: SparkChartLabelDisplayMode.all,
xValueMapper: (int index) => data[index].year,
yValueMapper: (int index) => data[index].sales,
dataCount: 5,
),
),
)
],
),
);
}
}
class _SalesData {
_SalesData(this.year, this.sales);
final String year;
final double sales;
}
// import 'package:flutter/material.dart';
// import 'package:syncfusion_flutter_charts/charts.dart';
// import 'package:syncfusion_flutter_charts/sparkcharts.dart';
//
// class SyncFuChart extends StatelessWidget {
// List<_SalesData> data = [
// _SalesData('Jan', 35),
// _SalesData('Feb', 28),
// _SalesData('Mar', 34),
// _SalesData('Apr', 32),
// _SalesData('May', 40),
// ];
//
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// body: Column(
// children: [
// //Initialize the chart widget
// SfCartesianChart(
//
// primaryXAxis: CategoryAxis(),
// primaryYAxis: CategoryAxis(minimum: 28),
// // Chart title
// title: ChartTitle(text: 'Half yearly sales analysis'),
// // Enable legend
// legend: Legend(isVisible: true),
// // Enable tooltip
// tooltipBehavior: TooltipBehavior(enable: true),
// series: <ChartSeries<_SalesData, String>>[
// LineSeries<_SalesData, String>(
// dataSource: data,
// xValueMapper: (_SalesData sales, _) => sales.year,
// yValueMapper: (_SalesData sales, _) => sales.sales,
// name: 'Sales',
// // Enable data label
// dataLabelSettings: DataLabelSettings(isVisible: true),
// ),
// ],
// ),
// ],
// ),
// );
// }
// }
//
// class _SalesData {
// _SalesData(this.year, this.sales);
//
// final String year;
// final double sales;
// }

@ -104,7 +104,7 @@ dependencies:
# Calendar
# table_calendar: ^2.3.0
syncfusion_flutter_calendar: ^18.4.49
syncfusion_flutter_charts: any
# syncfusion_flutter_charts: any
# SVG Images
flutter_svg: ^0.18.0

Loading…
Cancel
Save