Skip to content

Commit

Permalink
Merge pull request #54 from IamMuuo/dev
Browse files Browse the repository at this point in the history
Final Release candidate 1
  • Loading branch information
IamMuuo authored Feb 2, 2024
2 parents 2ce8dcf + ecf68b7 commit ca0fd74
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 95 deletions.
17 changes: 15 additions & 2 deletions lib/controllers/dashboard_controller.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:academia/constants/common.dart';
import 'package:academia/controllers/taskmanager_controller.dart';
import 'package:academia/models/courses.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
Expand All @@ -18,7 +19,13 @@ class DashboardController extends GetxController {
}

double get semesterPercent {
return 1;
var month = DateTime.now().month;
if (month > DateTime.january && month < DateTime.april) {
return month / DateTime.april;
} else if (month > DateTime.april && month < DateTime.july) {
return month / DateTime.july;
}
return month / DateTime.december;
}

String get getDayPercentQuote {
Expand Down Expand Up @@ -51,7 +58,7 @@ class DashboardController extends GetxController {
} else if (semesterPercent > 0.5) {
return "Its about to get real messy";
} else if (semesterPercent > 0.25) {
return "CATS CATS CATS, cats all the way";
return "CATS CATS, cats all the way";
}
return "Ready, aim shoot for the sky";
}
Expand All @@ -73,6 +80,12 @@ class DashboardController extends GetxController {
return classes;
}

int get numberofTasks {
var taskscontroller = Get.find<TaskManagerController>();
taskscontroller.getTasks();
return taskscontroller.tasks.length;
}

int get classesTommorrowCount {
int classes = 0;
var courses = appDB.get("timetable") ?? [];
Expand Down
116 changes: 67 additions & 49 deletions lib/pages/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class DashBoard extends StatelessWidget {
TextSpan(children: [
TextSpan(
text: "The semester is\n",
style: h5.copyWith(
style: h6.copyWith(
fontWeight: FontWeight.w300,
),
),
Expand Down Expand Up @@ -209,19 +209,18 @@ class DashBoard extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ClipRRect(
borderRadius: const BorderRadius.all(
Radius.circular(90),
),
child: CircleAvatar(
radius: 40,
child: Image.asset(
"assets/images/abc.png",
fit: BoxFit.scaleDown,
height: 50,
width: 50,
borderRadius: const BorderRadius.all(
Radius.circular(90),
),
),
),
child: CircleAvatar(
radius: 40,
child: Image.asset(
"assets/images/abc.png",
fit: BoxFit.scaleDown,
height: 50,
width: 50,
),
)),
Text(
"${dashBoardController.classesTodayCount}",
style: h3,
Expand Down Expand Up @@ -264,8 +263,8 @@ class DashBoard extends StatelessWidget {
),
),
),
const Text(
"0",
Text(
"${dashBoardController.numberofTasks}",
style: h3,
),
Text(
Expand Down Expand Up @@ -334,42 +333,61 @@ class DashBoard extends StatelessWidget {
const SizedBox(height: 12),
const Text("Upcoming events and classes", style: h6),
SizedBox(
height: 120,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: dashBoardController.classesTommorrow.length,
itemBuilder: ((context, index) {
return Padding(
padding: const EdgeInsets.all(12),
child: Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(
Radius.circular(12)),
color: Theme.of(context).primaryColorDark),
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
CircleAvatar(
radius: 20,
backgroundColor:
Theme.of(context).primaryColorLight,
child: const Icon(CupertinoIcons.timer),
),
Text(
dashBoardController
.classesTommorrow[index].name!,
style: normal.copyWith(
color: Theme.of(context)
.primaryColorLight),
height: 120,
child: dashBoardController.classesTommorrow.isNotEmpty
? ListView.builder(
scrollDirection: Axis.horizontal,
itemCount:
dashBoardController.classesTommorrow.length,
itemBuilder: ((context, index) {
return Padding(
padding: const EdgeInsets.all(12),
child: Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(
Radius.circular(12)),
color:
Theme.of(context).primaryColorDark),
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
CircleAvatar(
radius: 20,
backgroundColor:
Theme.of(context).primaryColorLight,
child: const Icon(CupertinoIcons.timer),
),
Text(
dashBoardController
.classesTommorrow[index].name!,
style: normal.copyWith(
color: Theme.of(context)
.primaryColorLight),
),
],
),
],
),
),
);
}),
)
: SizedBox(
// height: 20,
child: Column(
children: [
Image.asset(
"assets/images/having_coffee.png",
height: 80,
),
const Text(
"Seems you have nothing upcoming for tommorrow take the day off, cool off",
textAlign: TextAlign.center,
)
],
),
);
}),
))
),
)
],
),
),
Expand Down
30 changes: 30 additions & 0 deletions lib/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:academia/constants/common.dart';
import 'package:academia/controllers/login_controller.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';

Expand Down Expand Up @@ -37,6 +38,8 @@ class LoginPage extends StatelessWidget {
padding: const EdgeInsets.all(16),
child: TextField(
controller: loginController.usernameController,
textAlign: TextAlign.center,
inputFormatters: [AdmissionNumberFormatter()],
decoration: const InputDecoration(
hintText: 'Your admission number',
),
Expand All @@ -48,6 +51,7 @@ class LoginPage extends StatelessWidget {
() => TextField(
controller: loginController.passwordController,
obscureText: loginController.showPassword.value,
textAlign: TextAlign.center,
decoration: InputDecoration(
hintText: 'Your password',
suffixIcon: IconButton(
Expand Down Expand Up @@ -110,3 +114,29 @@ class LoginPage extends StatelessWidget {
);
}
}

class AdmissionNumberFormatter extends TextInputFormatter {
@override
TextEditingValue formatEditUpdate(
TextEditingValue oldValue, TextEditingValue newValue) {
final oldValueText = oldValue.text;
final newValueText = newValue.text;

if (newValueText == '') {
return newValue;
} else if (newValueText.length <= 2) {
return newValue;
} else if (newValueText.length == 3) {
return newValueText.endsWith('-')
? newValue
: TextEditingValue(
text:
"${newValueText.substring(0, 2)}-${newValueText.substring(2)}",
);
} else if (newValueText.length <= 7) {
return newValue;
} else {
return oldValue;
}
}
}
80 changes: 38 additions & 42 deletions lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SettingsPage extends StatelessWidget {
),
),
Positioned(
right: -2,
right: 3,
bottom: 0,
child: Icon(
CupertinoIcons.checkmark_seal_fill,
Expand All @@ -106,43 +106,38 @@ class SettingsPage extends StatelessWidget {
const SizedBox(
height: 12,
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.5,
child: ListView(
children: [
InfoCard(
title: "National ID",
content: user.idno ?? "Unknown",
icon: Icons.numbers,
),
InfoCard(
title: "Admission Number",
content: user.admno ?? "00-0000",
icon: Icons.person,
),
InfoCard(
title: "Gender",
content: (user.gender ?? "unknown").title(),
icon: Icons.female,
),
InfoCard(
title: "Email Address",
content: user.email ?? "[email protected]",
icon: Icons.email,
),
InfoCard(
title: "Address",
content: user.address ?? "unknown",
icon: Icons.mail,
),
InfoCard(
title: "Birthday",
content: (user.dateOfBirth ?? "unknown").title(),
icon: Icons.cake_sharp,
),
],
),
)
InfoCard(
title: "National ID",
content: user.idno ?? "Unknown",
icon: Icons.numbers,
),
InfoCard(
title: "Admission Number",
content: user.admno ?? "00-0000",
icon: Icons.person,
),
InfoCard(
title: "Gender",
content: (user.gender ?? "unknown").title(),
icon: (user.gender ?? "unknown").toLowerCase() == "male"
? Icons.male
: Icons.female,
),
InfoCard(
title: "Email Address",
content: user.email ?? "[email protected]",
icon: Icons.email,
),
InfoCard(
title: "Address",
content: user.address ?? "unknown",
icon: Icons.mail,
),
InfoCard(
title: "Birthday",
content: (user.dateOfBirth ?? "unknown").title(),
icon: Icons.cake_sharp,
),
],
),
),
Expand Down Expand Up @@ -180,10 +175,11 @@ class SettingsPage extends StatelessWidget {
borderRadius: const BorderRadius.all(
Radius.circular(50)),
child: CachedNetworkImage(
height: 65,
fit: BoxFit.contain,
imageUrl: snapshot.data![index]
["avatar_url"]),
height: 65,
fit: BoxFit.contain,
imageUrl: snapshot.data![index]
["avatar_url"],
),
),
),
Text(
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/dateTime_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class _DateTimePickerState extends State<DateTimePicker> {
children: [
IconButton(
onPressed: () => _selectDateTime(context),
icon: Icon(Icons.calendar_today),
icon: const Icon(Icons.calendar_today),
),
SizedBox(width: 8),
const SizedBox(width: 8),
Text(
selectedDateTime != null
? DateFormat('yyyy-MM-dd HH:mm').format(selectedDateTime)
Expand Down

0 comments on commit ca0fd74

Please sign in to comment.