Commit 72e11618 authored by Nilupul Jayasekara's avatar Nilupul Jayasekara

implement time frame to record screen

parent e98ff601
...@@ -127,7 +127,7 @@ class _DashboardScreenState extends State<DashboardScreen> { ...@@ -127,7 +127,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
builder: (context, AsyncSnapshot snapshot) { builder: (context, AsyncSnapshot snapshot) {
if (snapshot.hasData) { if (snapshot.hasData) {
int length = snapshot.data!.length; int length = snapshot.data!.length;
return ListView( return length >0 ? ListView(
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
children: List.generate( children: List.generate(
...@@ -152,6 +152,17 @@ class _DashboardScreenState extends State<DashboardScreen> { ...@@ -152,6 +152,17 @@ class _DashboardScreenState extends State<DashboardScreen> {
); );
}, },
), ),
): Padding(
padding: const EdgeInsets.only(top: 50.0),
child: Column(
children: [
Container(child: Center(child: Text(" No records, yet.")),),
SizedBox(
height: 8,
),
Container(child: Center(child: Text(" Add your first record.")),),
],
),
); );
} else { } else {
return const Center( return const Center(
......
...@@ -23,7 +23,7 @@ class _LogbookScreenState extends State<LogbookScreen> { ...@@ -23,7 +23,7 @@ class _LogbookScreenState extends State<LogbookScreen> {
builder: (context, AsyncSnapshot snapshot) { builder: (context, AsyncSnapshot snapshot) {
if (snapshot.hasData) { if (snapshot.hasData) {
int length = snapshot.data!.length; int length = snapshot.data!.length;
return ListView( return length>0 ? ListView(
shrinkWrap: true, shrinkWrap: true,
children: List.generate(length, (index) { children: List.generate(length, (index) {
return Center( return Center(
...@@ -44,7 +44,7 @@ class _LogbookScreenState extends State<LogbookScreen> { ...@@ -44,7 +44,7 @@ class _LogbookScreenState extends State<LogbookScreen> {
), ),
); );
}), }),
); ): Container(child: Center(child: Text("No data to display."),),);
} else { } else {
return const Center( return const Center(
child: CircularProgressIndicator(), child: CircularProgressIndicator(),
......
...@@ -206,7 +206,7 @@ class GlucoseLogService { ...@@ -206,7 +206,7 @@ class GlucoseLogService {
} }
static Future<List<LogEntry>> getRecordsByTimeFrame( static Future<List<LogEntry>> getRecordsByTimeFrame(
String accountId, String period) async { String accountId, String period, {bool isDecending = true}) async {
List<LogEntry> recordList = []; List<LogEntry> recordList = [];
DateTime date = DateTime.now(); DateTime date = DateTime.now();
...@@ -218,7 +218,7 @@ class GlucoseLogService { ...@@ -218,7 +218,7 @@ class GlucoseLogService {
.where("userId", isEqualTo: accountId) .where("userId", isEqualTo: accountId)
.where("dateTime", .where("dateTime",
isGreaterThanOrEqualTo: Timestamp.fromDate(firstDayOfWeek)) isGreaterThanOrEqualTo: Timestamp.fromDate(firstDayOfWeek))
.orderBy("dateTime", descending: true) .orderBy("dateTime", descending: isDecending)
.get() .get()
.then((QuerySnapshot querySnapshot) { .then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) { querySnapshot.docs.forEach((doc) {
...@@ -245,7 +245,7 @@ class GlucoseLogService { ...@@ -245,7 +245,7 @@ class GlucoseLogService {
.where("dateTime", .where("dateTime",
isGreaterThanOrEqualTo: isGreaterThanOrEqualTo:
Timestamp.fromDate(DateTime(now.year, now.month, 1))) Timestamp.fromDate(DateTime(now.year, now.month, 1)))
.orderBy("dateTime", descending: true) .orderBy("dateTime", descending: isDecending)
.get() .get()
.then((QuerySnapshot querySnapshot) { .then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) { querySnapshot.docs.forEach((doc) {
...@@ -272,7 +272,7 @@ class GlucoseLogService { ...@@ -272,7 +272,7 @@ class GlucoseLogService {
.where("dateTime", .where("dateTime",
isGreaterThanOrEqualTo: isGreaterThanOrEqualTo:
Timestamp.fromDate(DateTime(now.year, 1, 1))) Timestamp.fromDate(DateTime(now.year, 1, 1)))
.orderBy("dateTime", descending: true) .orderBy("dateTime", descending: isDecending)
.get() .get()
.then((QuerySnapshot querySnapshot) { .then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) { querySnapshot.docs.forEach((doc) {
...@@ -295,7 +295,7 @@ class GlucoseLogService { ...@@ -295,7 +295,7 @@ class GlucoseLogService {
} else if (period == "All records") { } else if (period == "All records") {
await _records await _records
.where("userId", isEqualTo: accountId) .where("userId", isEqualTo: accountId)
.orderBy("dateTime", descending: true) .orderBy("dateTime", descending: isDecending)
.get() .get()
.then((QuerySnapshot querySnapshot) { .then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) { querySnapshot.docs.forEach((doc) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment