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> {
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
int length = snapshot.data!.length;
return ListView(
return length >0 ? ListView(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
children: List.generate(
......@@ -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 {
return const Center(
......
......@@ -23,7 +23,7 @@ class _LogbookScreenState extends State<LogbookScreen> {
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
int length = snapshot.data!.length;
return ListView(
return length>0 ? ListView(
shrinkWrap: true,
children: List.generate(length, (index) {
return Center(
......@@ -44,7 +44,7 @@ class _LogbookScreenState extends State<LogbookScreen> {
),
);
}),
);
): Container(child: Center(child: Text("No data to display."),),);
} else {
return const Center(
child: CircularProgressIndicator(),
......
......@@ -206,7 +206,7 @@ class GlucoseLogService {
}
static Future<List<LogEntry>> getRecordsByTimeFrame(
String accountId, String period) async {
String accountId, String period, {bool isDecending = true}) async {
List<LogEntry> recordList = [];
DateTime date = DateTime.now();
......@@ -218,7 +218,7 @@ class GlucoseLogService {
.where("userId", isEqualTo: accountId)
.where("dateTime",
isGreaterThanOrEqualTo: Timestamp.fromDate(firstDayOfWeek))
.orderBy("dateTime", descending: true)
.orderBy("dateTime", descending: isDecending)
.get()
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
......@@ -245,7 +245,7 @@ class GlucoseLogService {
.where("dateTime",
isGreaterThanOrEqualTo:
Timestamp.fromDate(DateTime(now.year, now.month, 1)))
.orderBy("dateTime", descending: true)
.orderBy("dateTime", descending: isDecending)
.get()
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
......@@ -272,7 +272,7 @@ class GlucoseLogService {
.where("dateTime",
isGreaterThanOrEqualTo:
Timestamp.fromDate(DateTime(now.year, 1, 1)))
.orderBy("dateTime", descending: true)
.orderBy("dateTime", descending: isDecending)
.get()
.then((QuerySnapshot querySnapshot) {
querySnapshot.docs.forEach((doc) {
......@@ -295,7 +295,7 @@ class GlucoseLogService {
} else if (period == "All records") {
await _records
.where("userId", isEqualTo: accountId)
.orderBy("dateTime", descending: true)
.orderBy("dateTime", descending: isDecending)
.get()
.then((QuerySnapshot querySnapshot) {
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