Skip to content

Commit

Permalink
Version 1.0: Logo, Dialog, Logic complete
Browse files Browse the repository at this point in the history
  • Loading branch information
HossamElghamry committed Jul 5, 2019
1 parent af5d0ee commit 13332f1
Show file tree
Hide file tree
Showing 12 changed files with 234 additions and 97 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Mediminder"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/launcher_icon">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo/Mediminder_Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
157 changes: 128 additions & 29 deletions lib/src/ui/medicine_details/medicine_details.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:medicine_reminder/src/models/medicine.dart';
import 'package:provider/provider.dart';

Expand Down Expand Up @@ -42,39 +43,136 @@ class MedicineDetails extends StatelessWidget {
),
ExtendedSection(medicine: medicine),
Padding(
padding: EdgeInsets.only(
left: MediaQuery.of(context).size.height * 0.06,
right: MediaQuery.of(context).size.height * 0.06,
top: 25,
padding: EdgeInsets.only(
left: MediaQuery.of(context).size.height * 0.06,
right: MediaQuery.of(context).size.height * 0.06,
top: 25,
),
child: Container(
width: 280,
height: 70,
child: FlatButton(
color: Color(0xFF3EB16F),
shape: StadiumBorder(),
onPressed: () {
openAlertBox(context, _globalBloc);
},
child: Center(
child: Text(
"Delete Mediminder",
style: TextStyle(
color: Colors.white,
fontSize: 22,
fontWeight: FontWeight.w700,
),
),
),
),
),
),
],
),
),
),
);
}

openAlertBox(BuildContext context, GlobalBloc _globalBloc) {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(30.0),
),
),
contentPadding: EdgeInsets.only(top: 10.0),
content: Container(
width: 300.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: EdgeInsets.all(18),
child: Center(
child: Text(
"Delete this Mediminder?",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16, fontWeight: FontWeight.bold),
),
),
),
child: Container(
width: 280,
height: 70,
child: FlatButton(
color: Color(0xFF3EB16F),
shape: StadiumBorder(),
onPressed: () {
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
GestureDetector(
onTap: () {
_globalBloc.removeMedicine(medicine);
Navigator.popUntil(
context,
ModalRoute.withName('/'),
);
},
child: InkWell(
child: Container(
width: MediaQuery.of(context).size.width / 2.743,
padding: EdgeInsets.only(top: 15.0, bottom: 15.0),
decoration: BoxDecoration(
color: Color(0xFF3EB16F),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(30.0),
),
),
child: Text(
"Yes",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
),
),
),
GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
child: Center(
child: Text(
"Delete Mediminder",
style: TextStyle(
color: Colors.white,
fontSize: 22,
fontWeight: FontWeight.w700,
child: InkWell(
child: Container(
width: MediaQuery.of(context).size.width / 2.743,
padding: EdgeInsets.only(top: 15.0, bottom: 15.0),
decoration: BoxDecoration(
color: Colors.red[700],
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(30.0)),
),
child: Text(
"No",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
),
),
))),
],
),
),
),
);
),
],
)
],
),
),
);
});
}
}
// _globalBloc.removeMedicine(medicine);
// Navigator.of(context).pop()

class MainSection extends StatelessWidget {
final Medicine medicine;
Expand Down Expand Up @@ -155,7 +253,9 @@ class MainSection extends StatelessWidget {
),
MainInfoTab(
fieldTitle: "Dosage",
fieldInfo: medicine.dosage.toString() + " mg",
fieldInfo: medicine.dosage == 0
? "Not Specified"
: medicine.dosage.toString() + " mg",
)
],
)
Expand Down Expand Up @@ -191,7 +291,7 @@ class MainInfoTab extends StatelessWidget {
Text(
fieldInfo,
style: TextStyle(
fontSize: 26,
fontSize: 24,
color: Color(0xFF3EB16F),
fontWeight: FontWeight.bold),
),
Expand Down Expand Up @@ -222,9 +322,8 @@ class ExtendedSection extends StatelessWidget {
fieldTitle: "Dose Interval",
fieldInfo: "Every " +
medicine.interval.toString() +
" hour(s) | " +
(24 / medicine.interval).floor().toString() +
" time(s) a day",
" hours | " +
" ${medicine.interval == 24 ? "One time a day" : (24 / medicine.interval).floor().toString() + " times a day"}",
),
ExtendedInfoTab(
fieldTitle: "Start Time",
Expand Down
78 changes: 33 additions & 45 deletions lib/src/ui/new_entry/new_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ class _NewEntryState extends State<NewEntry> {
child: Provider<NewEntryBloc>.value(
value: _newEntryBloc,
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 25, vertical: 10),
padding: EdgeInsets.symmetric(
horizontal: 25,
),
children: <Widget>[
PanelTitle(
title: "Medicine Name",
isRequired: true,
),
TextFormField(
maxLength: 12,
style: TextStyle(
fontSize: 16,
),
Expand All @@ -85,12 +88,9 @@ class _NewEntryState extends State<NewEntry> {
border: UnderlineInputBorder(),
),
),
SizedBox(
height: 10,
),
PanelTitle(
title: "Dosage in mg",
isRequired: true,
isRequired: false,
),
TextFormField(
controller: dosageController,
Expand All @@ -103,6 +103,10 @@ class _NewEntryState extends State<NewEntry> {
border: UnderlineInputBorder(),
),
),
SizedBox(
height: 15,
),

PanelTitle(
title: "Medicine Type",
isRequired: false,
Expand Down Expand Up @@ -178,7 +182,7 @@ class _NewEntryState extends State<NewEntry> {
"Confirm",
style: TextStyle(
color: Colors.white,
fontSize: 26,
fontSize: 28,
fontWeight: FontWeight.w700,
),
),
Expand All @@ -188,23 +192,18 @@ class _NewEntryState extends State<NewEntry> {
int dosage;
//--------------------Error Checking------------------------
//Had to do error checking in UI
//Due to unoptimized BLoC error checking architecture
//Due to unoptimized BLoC value-grabbing architecture
if (nameController.text == "") {
print("error");
_newEntryBloc.submitError(EntryError.NameNull);
return;
}
if (nameController.text != "") {
print("noerror");
medicineName = nameController.text;
}
if (dosageController.text == "") {
print("error");
_newEntryBloc.submitError(EntryError.Dosage);
return;
dosage = 0;
}
if (dosageController.text != "") {
print("noerror");
dosage = int.parse(dosageController.text);
}
for (var medicine in _globalBloc.medicineList$.value) {
Expand Down Expand Up @@ -312,7 +311,7 @@ class _NewEntryState extends State<NewEntry> {

initializeNotifications() async {
var initializationSettingsAndroid =
AndroidInitializationSettings('@mipmap/ic_launcher');
AndroidInitializationSettings('@mipmap/launcher_icon');
var initializationSettingsIOS = IOSInitializationSettings();
var initializationSettings = InitializationSettings(
initializationSettingsAndroid, initializationSettingsIOS);
Expand Down Expand Up @@ -353,8 +352,10 @@ class _NewEntryState extends State<NewEntry> {
}
await flutterLocalNotificationsPlugin.showDailyAtTime(
int.parse(medicine.notificationIDs[i]),
'Medicine Reminder: ${medicine.medicineName}',
'It is time to take your ${medicine.medicineName + " " + medicine.medicineType}, according to schedule',
'Mediminder: ${medicine.medicineName}',
medicine.medicineType.toString() == MedicineType.None.toString()
? 'It is time to take your ${medicine.medicineType.toLowerCase()}, according to schedule'
: 'It is to time to take your medicine, according to schedule',
Time(hour, minute, 0),
platformChannelSpecifics);
hour = ogValue;
Expand Down Expand Up @@ -395,6 +396,7 @@ class _IntervalSelectionState extends State<IntervalSelection> {
),
),
DropdownButton<int>(
iconEnabledColor: Color(0xFF3EB16F),
hint: _selected == 0
? Text(
"Select an Interval",
Expand Down Expand Up @@ -470,42 +472,28 @@ class _SelectTimeState extends State<SelectTime> {
@override
Widget build(BuildContext context) {
return Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 8.0, bottom: 4),
child: FlatButton(
color: Color(0xFF3EB16F),
shape: StadiumBorder(),
onPressed: () {
_selectTime(context);
},
child: Center(
child: Text(
_clicked == false ? "Pick Time" : "Edit Time",
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
),
),
),
Center(
height: 60,
child: Padding(
padding: EdgeInsets.only(top: 10.0, bottom: 4),
child: FlatButton(
color: Color(0xFF3EB16F),
shape: StadiumBorder(),
onPressed: () {
_selectTime(context);
},
child: Center(
child: Text(
_clicked == false
? ""
: "Selected starting time: ${convertTime(_time.hour.toString())}:${convertTime(_time.minute.toString())}",
? "Pick Time"
: "${convertTime(_time.hour.toString())}:${convertTime(_time.minute.toString())}",
style: TextStyle(
color: Colors.black,
fontSize: 16,
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
),
],
),
),
);
}
Expand Down
Loading

0 comments on commit 13332f1

Please sign in to comment.