Skip to content

Commit cad973b

Browse files
committed
fiexing commit
1 parent ed598fe commit cad973b

26 files changed

+55
-131
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.drinkable.drinkable">
3-
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
4-
calls FlutterMain.startInitialization(this); in its onCreate method.
5-
In most cases you can leave this as-is, but you if you want to provide
6-
additional functionality it is fine to subclass or reimplement
7-
FlutterApplication and put your custom class here. -->
8-
93
<uses-permission android:name="android.permission.INTERNET"/>
4+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
105

116
<application
127
android:name="io.flutter.app.FlutterApplication"

assets/icons/bottle.png

-2.25 KB
Binary file not shown.

assets/icons/glass.png

-2.09 KB
Binary file not shown.

lib/models/water_amount.dart

Lines changed: 0 additions & 15 deletions
This file was deleted.

lib/providers/auth_provider.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
import 'package:drinkable/models/app_user.dart';
21
import 'package:flutter/foundation.dart';
32
import 'package:cloud_firestore/cloud_firestore.dart';
43
import 'package:firebase_auth/firebase_auth.dart';
54
import 'package:flutter/material.dart';
65
import 'package:google_sign_in/google_sign_in.dart';
76

7+
// models
8+
import '../models/app_user.dart';
9+
10+
811
class AuthProvider extends ChangeNotifier {
912
FirebaseFirestore _firestore = FirebaseFirestore.instance;
1013
GoogleSignIn _googleSignIn = GoogleSignIn();

lib/providers/home_provider.dart

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@ import '../models/weekly_data.dart';
1212
import '../models/app_user.dart';
1313

1414
class HomeProvider extends ChangeNotifier {
15+
FirebaseFirestore _firebaseFirestore = FirebaseFirestore.instance;
16+
Location _location = Location();
1517
bool _isInited = false;
18+
DateTime _today = DateTime.now();
19+
1620
WeeklyData _weeklyData;
1721
String _uid;
1822
AppUser _appUser;
19-
DateTime _today = DateTime.now();
20-
FirebaseFirestore _firebaseFirestore = FirebaseFirestore.instance;
23+
2124
CollectionReference _weekColRef;
2225
DocumentReference _userRef;
2326
DocumentReference _currentWeek;
24-
Location _location = Location();
27+
2528
Map<String,dynamic> _weather;
2629
LocationData _locationData;
2730

2831
void update(User user){
29-
print('Updating user in home provider');
3032
if(user!=null){
3133
_uid = user.uid;
3234
_weekColRef = _firebaseFirestore.collection('users').doc(_uid).collection('weeks');
@@ -52,18 +54,13 @@ class HomeProvider extends ChangeNotifier {
5254
}else{
5355
return '${(target/1000).toStringAsFixed(1)} L';
5456
}
55-
//return _user.dailyTarget;
5657
}
5758

58-
String get leftAmount {
59+
int get leftAmount {
5960
int target = _appUser.dailyTarget;
6061
int consumed = _weeklyData.amounts[_today.weekday.toString()].toInt();
6162
int left = target-consumed;
62-
if(left<1000){
63-
return '$left mL';
64-
}else{
65-
return '${(left/1000).toStringAsFixed(1)} L';
66-
}
63+
return left;
6764
}
6865

6966
double get targetReached {
@@ -92,11 +89,8 @@ class HomeProvider extends ChangeNotifier {
9289
}
9390
_isInited = true;
9491
bool canGetLocation = await getLocationService();
95-
print(canGetLocation);
9692
if(canGetLocation){
9793
_locationData = await _location.getLocation();
98-
print(_locationData.latitude);
99-
print(_locationData.longitude);
10094
http.Response response = await http.get(
10195
'https://api.openweathermap.org/data/2.5/weather?lat=${_locationData.latitude}&lon=${_locationData.longitude}&appid=5c079888a15f3da50f160e44ce22723e&units=metric'
10296
);
@@ -119,7 +113,7 @@ class HomeProvider extends ChangeNotifier {
119113
int weekday = time.weekday;
120114
int week = getWeek(time);
121115
String weekId = '${time.year}_$week';
122-
_firebaseFirestore.runTransaction((transaction)async{
116+
await _firebaseFirestore.runTransaction((transaction)async{
123117
DocumentReference weekDocRef = _firebaseFirestore.collection('users').doc(_uid).collection('weeks').doc(weekId);
124118
DocumentReference yearDocRef = _firebaseFirestore.collection('users').doc(_uid).collection('years').doc('${time.year}');
125119
DocumentReference monthDocRef = _firebaseFirestore.collection('users').doc(_uid).collection('months').doc('${time.year}_${time.month}');
@@ -142,10 +136,11 @@ class HomeProvider extends ChangeNotifier {
142136

143137
if(!weekDocSnap.exists){
144138
transaction.set(weekDocRef, {
139+
'daily_target' : _appUser.dailyTarget,
145140
'year' : time.year,
146141
'month' : time.month,
147142
'week' : week,
148-
'id' : weekId
143+
'id' : weekId,
149144
},SetOptions(merge: true));
150145
}
151146

@@ -173,12 +168,10 @@ class HomeProvider extends ChangeNotifier {
173168

174169
Future<bool> getLocationService()async{
175170
bool isServiceEnabled = await _location.serviceEnabled();
176-
print(isServiceEnabled);
177171

178172
if(!isServiceEnabled){
179173
bool _enabled = await _location.requestService();
180174
if (_enabled) {
181-
print('Service is enabled now');
182175
}else{
183176
return false;
184177
}

lib/providers/statistics_provider.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class StatisticsProvider extends ChangeNotifier {
2626
Future<void> init() async {
2727
try {
2828
_weeklyData.clear();
29-
QuerySnapshot snapshot = await _weeksRef.orderBy('id').limit(4).get();
29+
QuerySnapshot snapshot = await _weeksRef.orderBy('id',descending: true).limit(4).get();
3030
List<QueryDocumentSnapshot> docsSnap = snapshot.docs;
3131
docsSnap.forEach((docSnap) {
3232
_weeklyData.add(new WeeklyData.fromDoc(docSnap.data()));

lib/screens/auth_screen.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import '../providers/auth_provider.dart';
1010
// screens
1111
import '../screens/data_entry_screen.dart';
1212

13+
// widgets
14+
import '../widgets/custom_progress_indicator.dart';
15+
1316

1417
class AuthScreen extends StatefulWidget {
1518
static const routeName = 'auth-screen';
@@ -39,7 +42,6 @@ class _AuthScreenState extends State<AuthScreen> {
3942
void selectAccount(BuildContext ctx) async {
4043
toggleLoading();
4144
bool newuser = await Provider.of<AuthProvider>(ctx,listen: false).selectGoogleAcount();
42-
print('new user $newuser');
4345
if(!newuser){
4446
await Provider.of<AuthProvider>(ctx,listen: false).signIn();
4547
}else{
@@ -90,7 +92,7 @@ class _AuthScreenState extends State<AuthScreen> {
9092
Column(
9193
mainAxisSize: MainAxisSize.min,
9294
children: [
93-
_loading ? CircularProgressIndicator() : Consumer<AuthProvider>(
95+
_loading ? CustomProgressIndicatior() : Consumer<AuthProvider>(
9496
builder: (ctx, authProvider, child) {
9597
GoogleSignInAccount googleAccount = authProvider.googleAcount;
9698
return googleAccount!=null ?

lib/screens/data_entry_screen.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import '../utils/time_converter.dart';
1212

1313
// widgets
1414
import '../widgets/custom_form_field.dart';
15+
import '../widgets/custom_progress_indicator.dart';
16+
1517

1618

1719
class DataEntryScreen extends StatelessWidget {
@@ -355,12 +357,9 @@ class _DataEntryFormState extends State<DataEntryForm> {
355357
RaisedButton(
356358
elevation: 1,
357359
color: Color.fromARGB(255, 0, 60, 192),
358-
359360
child: _loading ? SizedBox(
360361
height: 22,width: 22,
361-
child: CircularProgressIndicator(
362-
strokeWidth: 2,
363-
)
362+
child: CustomProgressIndicatior()
364363
) : Text(
365364
'Let\'t go',
366365
style: GoogleFonts.poppins(

lib/screens/home_screen.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import '../providers/auth_provider.dart';
1818
import '../models/app_user.dart';
1919

2020
// widgets
21+
import '../widgets/custom_progress_indicator.dart';
2122
import '../widgets/custom_form_field.dart';
2223

2324
class HomeScreen extends StatefulWidget {
@@ -206,7 +207,7 @@ class _AddWaterWidgetState extends State<AddWaterWidget> {
206207
if(value.isEmpty){
207208
return 'Enter water amount';
208209
}
209-
if(double.parse(value)<0){
210+
if(double.parse(value)<=0){
210211
return 'Wrong value';
211212
}
212213
if(double.parse(value)>appUser.dailyTarget){
@@ -243,7 +244,10 @@ class _AddWaterWidgetState extends State<AddWaterWidget> {
243244
),
244245
FlatButton(
245246
color: Color.fromARGB(255, 0, 60, 192),
246-
child: Text('Create',
247+
child: _loading ? SizedBox(
248+
height: 22,width: 22,
249+
child: CustomProgressIndicatior()
250+
) : Text('Add',
247251
style: GoogleFonts.poppins(
248252
fontSize: 13,
249253
fontWeight: FontWeight.w500

lib/screens/profile_screen.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import 'package:flutter/material.dart';
32
import 'package:provider/provider.dart';
43
import 'package:firebase_auth/firebase_auth.dart';
@@ -15,6 +14,7 @@ import '../models/app_user.dart';
1514
// widgets
1615
import '../widgets/custom_app_bar.dart';
1716
import '../widgets/custom_form_field.dart';
17+
import '../widgets/custom_progress_indicator.dart';
1818

1919
// utils
2020
import '../utils/time_converter.dart';
@@ -356,9 +356,7 @@ class _DataEntryFormState extends State<DataEntryForm> {
356356

357357
child: _loading ? SizedBox(
358358
height: 22,width: 22,
359-
child: CircularProgressIndicator(
360-
strokeWidth: 2,
361-
)
359+
child: CustomProgressIndicatior()
362360
) : Text(
363361
'Update',
364362
style: GoogleFonts.poppins(

lib/screens/scatistics_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import '../providers/auth_provider.dart';
99
import '../providers/statistics_provider.dart';
1010

1111
// models
12-
import 'package:drinkable/models/weekly_data.dart';
12+
import '../models/weekly_data.dart';
1313

1414
// widgets
1515
import '../widgets/custom_app_bar.dart';

lib/values/water_amount_types.dart

Lines changed: 0 additions & 32 deletions
This file was deleted.

lib/widgets/custom_drawer.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,8 @@ class _CustomDrawerState extends State<CustomDrawer> with SingleTickerProviderSt
8686
children: [
8787
Container(
8888
padding: EdgeInsets.symmetric(
89-
//horizontal: 25,
9089
vertical: 35
9190
),
92-
//color: Color.fromARGB(255,0, 11, 33),
9391
child: Column(
9492
children: [
9593
Padding(
@@ -213,7 +211,7 @@ class MenuItem extends StatelessWidget {
213211
children: [
214212
Icon(this.icon,color: Colors.white,size: 21,),
215213
SizedBox(width: 15,),
216-
Text(this.title,style: GoogleFonts.poppins(color: Colors.white,fontSize: 15),),
214+
Text(this.title,style: GoogleFonts.poppins(color: Colors.white,fontSize: 14),),
217215
],
218216
),
219217
),

lib/widgets/daily_amout_dial.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,23 @@ class DailyAmountDial extends StatelessWidget {
1818
Transform.rotate(
1919
angle: -pi/2,
2020
child: Container(
21-
width: 180,
22-
height: 180,
21+
width: 170,
22+
height: 170,
2323
child: CustomPaint(
2424
painter: DialPainter(provider.targetReached),
2525
),
2626
),
2727
),
28-
RichText(
28+
provider.leftAmount<=0 ? Text(
29+
'Goal Reached',
30+
style: GoogleFonts.poppins(fontSize: 16,fontWeight: FontWeight.w500,color: Colors.white,)
31+
):RichText(
2932
textAlign: TextAlign.center,
3033
text: TextSpan(
3134
children: [
3235
TextSpan(
33-
text: provider.leftAmount,
34-
style: GoogleFonts.poppins(fontSize: 33,fontWeight: FontWeight.w700)
36+
text: provider.leftAmount<1000? '${provider.leftAmount} mL': '${(provider.leftAmount/1000).toStringAsFixed(1)} L' ,
37+
style: GoogleFonts.poppins(fontSize: 30,fontWeight: FontWeight.w600)
3538
),
3639
TextSpan(text:'\n'),
3740
TextSpan(

lib/widgets/weather_suggestion.dart

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class WeatherSuggestion extends StatelessWidget {
1818
children: [
1919
Text(
2020
'Weather',
21-
style: GoogleFonts.poppins(fontSize: 22),
21+
style: GoogleFonts.poppins(fontSize: 20),
2222
),
23-
SizedBox(height: 20,),
23+
SizedBox(height: 18,),
2424
Consumer<HomeProvider>(
2525
builder: (context, value, child) {
2626
Map<String,dynamic> weather = value.weather;
@@ -48,20 +48,24 @@ class WeatherSuggestion extends StatelessWidget {
4848
children: [
4949
RichText(
5050
text: TextSpan(
51+
style: GoogleFonts.poppins(
52+
color: Colors.black,fontSize: 17,
53+
),
5154
children: [
52-
TextSpan(text: 'It\'s ',style: GoogleFonts.poppins(color: Colors.black,fontSize: 20,fontWeight: FontWeight.w300)),
53-
TextSpan(text: weather['description'],style: GoogleFonts.poppins(color: Colors.black,fontSize: 20,fontWeight: FontWeight.w700)),
54-
TextSpan(text: ' today!',style: GoogleFonts.poppins(color: Colors.black,fontSize: 20,fontWeight: FontWeight.w300)),
55+
TextSpan(text: 'It\'s ',style: GoogleFonts.poppins(fontWeight: FontWeight.w300)),
56+
TextSpan(text: weather['description'],style: GoogleFonts.poppins(fontWeight: FontWeight.w700)),
57+
TextSpan(text: ' today!',style: GoogleFonts.poppins(fontWeight: FontWeight.w300)),
5558
]
5659
),
5760
),
58-
SizedBox(height: 15,),
61+
SizedBox(height: 11,),
5962
Text(
6063
'Dont\'t forget to take the water bottle with you.',
6164
style: GoogleFonts.poppins(
6265
height: 1.5,
63-
color: Colors.black.withOpacity(0.6)
64-
),
66+
color: Colors.black.withOpacity(0.6),
67+
fontSize: 12
68+
),
6569
)
6670
],
6771
),

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A Flutter application which keeps track your water intake and remin
33

44
publish_to: 'none'
55

6-
version: 1.0.0+1
6+
version: 1.0.0
77

88
environment:
99
sdk: ">=2.7.0 <3.0.0"

screenshot/flutter_01.png

132 KB
Loading

screenshot/flutter_02.png

112 KB
Loading

screenshot/flutter_03.png

104 KB
Loading

screenshot/flutter_04.png

152 KB
Loading

screenshot/flutter_05.png

130 KB
Loading

screenshot/flutter_06.png

108 KB
Loading

screenshot/flutter_07.png

131 KB
Loading

screenshot/flutter_08.png

145 KB
Loading

0 commit comments

Comments
 (0)