Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added previous button in QuizView and toggleable radio #71

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion aptiche/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import 'package:aptiche/services/theme_service.dart';
import 'package:aptiche/utils/bindings.dart';
import 'package:aptiche/utils/theme.dart';
import 'package:aptiche/views/result/error404.dart';
import 'package:aptiche/views/splashscreen/splashscreen.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
HomeBinding().dependencies();
await Firebase.initializeApp();
await GetStorage.init();
runApp(MyApp());
}

Expand All @@ -28,9 +31,15 @@ class MyApp extends StatelessWidget {
}
if (snapshot.connectionState == ConnectionState.done) {
return GetMaterialApp(
builder: (BuildContext context, Widget? child) {
return ScrollConfiguration(
behavior: MyBehavior(), child: child!);
},
title: 'APTI-CHE',
debugShowCheckedModeBanner: false,
theme: appTheme(),
themeMode: Get.find<ThemeService>().theme,
theme: AppThemes.lightThemeData,
darkTheme: AppThemes.darkThemeData,
enableLog: true,
defaultTransition: Transition.rightToLeftWithFade,
popGesture: Get.isPopGestureEnable,
Expand All @@ -41,3 +50,12 @@ class MyApp extends StatelessWidget {
});
}
}

// Custom scroll Behavior to remove scroll glow
class MyBehavior extends ScrollBehavior {
@override
Widget buildViewportChrome(
BuildContext context, Widget child, AxisDirection axisDirection) {
return child;
}
}
30 changes: 30 additions & 0 deletions aptiche/lib/services/theme_service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';

class ThemeService extends GetxController {
final GetStorage _getStorage = GetStorage();
final String _isDarkModeKey = 'isDarkMode';
RxBool isDarkMode = false.obs;

@override
void onInit() {
isDarkMode.value = _getStorage.read<bool>(_isDarkModeKey) ?? false;
super.onInit();
}

/// Get isDarkMode info from local storage and return ThemeMode
ThemeMode get theme => isDarkMode.value ? ThemeMode.dark : ThemeMode.light;

/// Save isDarkMode to local storage
void _saveThemeToBox(bool isDarkMode) async =>
await _getStorage.write(_isDarkModeKey, isDarkMode);

/// Switch theme and save to local storage
void switchTheme() {
isDarkMode.value = !isDarkMode.value;

Get.changeThemeMode(isDarkMode.value ? ThemeMode.dark : ThemeMode.light);
_saveThemeToBox(isDarkMode.value);
}
}
2 changes: 2 additions & 0 deletions aptiche/lib/utils/bindings.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:aptiche/services/graphql.dart';
import 'package:aptiche/services/net/authservice.dart';
import 'package:aptiche/services/net/remote_config.dart';
import 'package:aptiche/services/theme_service.dart';
import 'package:aptiche/services/third_party_services.dart';
import 'package:aptiche/views/dataentry/dataentry_controller.dart';
import 'package:aptiche/views/home/home_controller.dart';
Expand All @@ -15,6 +16,7 @@ class HomeBinding implements Bindings {
Get.lazyPut<RemoteConfigService>(() => RemoteConfigService(), fenix: true);
Get.lazyPut<GraphQLService>(() => GraphQLService(), fenix: true);
Get.lazyPut<AuthService>(() => AuthService(), fenix: true);
Get.lazyPut<ThemeService>(() => ThemeService(), fenix: true);
Get.lazyPut<LoginController>(() => LoginController(), fenix: true);
Get.lazyPut<ThirdPartyServices>(() => ThirdPartyServices(), fenix: true);
Get.lazyPut<DataEntryController>(() => DataEntryController(), fenix: true);
Expand Down
67 changes: 63 additions & 4 deletions aptiche/lib/utils/theme.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_classes_with_only_static_members

import 'package:flutter/material.dart';

//colour used for buttons and other widgets
Expand All @@ -21,16 +23,17 @@ const Color kSnackColour = Color(0xffade8f4);
const String kPoppins = 'Poppins';
const String kSfpro = 'SFPro';

ThemeData appTheme() {
return ThemeData(
class AppThemes {
static final ThemeData lightThemeData = ThemeData(
backgroundColor: kBgColour,
appBarTheme: const AppBarTheme(
color: kBgColour,
iconTheme: IconThemeData(color: kTextColourBlue),
color: kGreyBgColor,
centerTitle: true,
),
primaryColor: kPrimaryColor,
secondaryHeaderColor: kSecondaryColor,
scaffoldBackgroundColor: kBgColour,
scaffoldBackgroundColor: kGreyBgColor,
primaryTextTheme: const TextTheme(
//Heading in Login-SignUp Screens, Quiz Heading in instruction page, Result diplay
headline1: TextStyle(
Expand Down Expand Up @@ -72,5 +75,61 @@ ThemeData appTheme() {
color: kTextColourBlack,
),
),
iconTheme: const IconThemeData(color: kTextColourBlue, opacity: 0.8),
);

static final ThemeData darkThemeData = ThemeData(
canvasColor: Colors.black,
backgroundColor: Colors.black,
appBarTheme: const AppBarTheme(
iconTheme: IconThemeData(color: Colors.white),
color: Colors.black,
centerTitle: true,
),
primaryColor: Colors.black,
secondaryHeaderColor: kSecondaryColor,
scaffoldBackgroundColor: Colors.black,
primaryTextTheme: const TextTheme(
//Heading in Login-SignUp Screens, Quiz Heading in instruction page, Result diplay
headline1: TextStyle(
fontSize: 32,
fontFamily: kSfpro,
fontWeight: FontWeight.w700,
color: Colors.white,
),

//Appbar titles
headline2: TextStyle(
fontSize: 22,
fontFamily: kPoppins,
fontWeight: FontWeight.w500,
color: Colors.white,
),

// Quiz titles in cards
headline3: TextStyle(
fontSize: 17,
fontFamily: kSfpro,
fontWeight: FontWeight.w500,
color: kTextColourBlue,
),
//textbox label texts, drawer screen texts, sub-headings in quiz and instruction pages
bodyText1: TextStyle(
fontSize: 14,
fontFamily: kSfpro,
fontWeight: FontWeight.w500,
color: Colors.white,
),

//general text
bodyText2: TextStyle(
fontSize: 12,
fontFamily: kPoppins,
fontWeight: FontWeight.normal,
color: kTextColourBlack,
),
),
iconTheme: const IconThemeData(
color: Colors.white,
));
}
10 changes: 5 additions & 5 deletions aptiche/lib/views/dataentry/dataentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ class DataEntryScreen extends GetView<DataEntryController> {
future: controller.readUser(),
builder: (BuildContext context, AsyncSnapshot<String?> snapshot) {
if (snapshot.data == null) {
return const Scaffold(
backgroundColor: Color(0xfff6f6f6),
body: Center(
return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
body: const Center(
child: CircularProgressIndicator(
backgroundColor: kPrimaryColor,
),
),
);
}
return Scaffold(
backgroundColor: const Color(0xfff6f6f6),
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
body: SafeArea(
child: Stack(
fit: StackFit.loose,
Expand All @@ -54,7 +54,7 @@ class DataEntryScreen extends GetView<DataEntryController> {
top: SizeConfig.safeBlockVertical! * 4,
),
decoration: BoxDecoration(
color: kBgColour,
color: Theme.of(context).backgroundColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(
SizeConfig.safeBlockHorizontal! * 10,
Expand Down
12 changes: 5 additions & 7 deletions aptiche/lib/views/drawer/aiche.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:aptiche/utils/string.dart';
import 'package:aptiche/utils/theme.dart';
import 'package:aptiche/utils/ui_scaling.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
Expand All @@ -10,23 +9,19 @@ class AboutAICHE extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: kBgColour,
appBar: AppBar(
elevation: 6,
leading: IconButton(
icon: const Icon(Icons.arrow_back_rounded),
color: kTextColourBlue,
onPressed: () {
Get.back<dynamic>();
},
),
centerTitle: false,
backgroundColor: kBgColour,
title: Text(
'AIChE',
style: Theme.of(context).textTheme.bodyText1!.copyWith(
style: Theme.of(context).primaryTextTheme.headline2!.copyWith(
fontSize: SizeConfig.safeBlockHorizontal! * 7,
color: kTextColourBlue,
fontWeight: FontWeight.w600,
),
)),
Expand All @@ -41,6 +36,9 @@ class AboutAICHE extends StatelessWidget {
width: SizeConfig.screenWidth! * 0.7,
child: Image.asset(
'assets/images/aiche.png',
color: Theme.of(context).backgroundColor == Colors.black
? Colors.white
: null,
alignment: Alignment.center,
),
),
Expand All @@ -51,7 +49,7 @@ class AboutAICHE extends StatelessWidget {
child: Text(
Strings.aiche,
textAlign: TextAlign.left,
style: Theme.of(context).textTheme.bodyText1!.copyWith(
style: Theme.of(context).primaryTextTheme.bodyText1!.copyWith(
fontSize: SizeConfig.safeBlockHorizontal! * 4.5,
fontWeight: FontWeight.w400,
),
Expand Down
15 changes: 5 additions & 10 deletions aptiche/lib/views/drawer/aichenitr.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:aptiche/utils/string.dart';
import 'package:aptiche/utils/theme.dart';
import 'package:aptiche/utils/ui_scaling.dart';
import 'package:flutter/material.dart';

Expand All @@ -11,25 +10,18 @@ class AboutAICHENITR extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: kBgColour,
appBar: AppBar(
elevation: 6,
leading: IconButton(
icon: const Icon(Icons.arrow_back_rounded),
color: kTextColourBlue,
onPressed: () {
Get.back<dynamic>();
},
),
centerTitle: false,
backgroundColor: kBgColour,
title: Text(
'AIChE NIT Rourkela',
style: Theme.of(context).textTheme.bodyText1!.copyWith(
fontSize: SizeConfig.safeBlockHorizontal! * 7,
color: kTextColourBlue,
fontWeight: FontWeight.w600,
),
style: Theme.of(context).primaryTextTheme.headline2,
)),
body: SingleChildScrollView(
child: Padding(
Expand All @@ -42,6 +34,9 @@ class AboutAICHENITR extends StatelessWidget {
width: SizeConfig.screenWidth! * 0.5,
child: Image.asset(
'assets/images/aichenitr.png',
color: Theme.of(context).backgroundColor == Colors.black
? Colors.white
: null,
alignment: Alignment.center,
),
),
Expand All @@ -52,7 +47,7 @@ class AboutAICHENITR extends StatelessWidget {
child: Text(
Strings.aiche_nitr,
textAlign: TextAlign.left,
style: Theme.of(context).textTheme.bodyText1!.copyWith(
style: Theme.of(context).primaryTextTheme.bodyText1!.copyWith(
fontSize: SizeConfig.safeBlockHorizontal! * 4.5,
fontWeight: FontWeight.w400,
),
Expand Down
24 changes: 10 additions & 14 deletions aptiche/lib/views/drawer/dev_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,18 @@ class DevInfo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: kBgColour,
appBar: AppBar(
elevation: 6,
leading: IconButton(
icon: const Icon(Icons.arrow_back_rounded),
color: kTextColourBlue,
onPressed: () {
Get.back<dynamic>();
},
),
centerTitle: false,
backgroundColor: kBgColour,
title: Text(
'Developer Info',
style: Theme.of(context).textTheme.bodyText1!.copyWith(
fontSize: SizeConfig.safeBlockHorizontal! * 7,
color: kTextColourBlue,
fontWeight: FontWeight.w600,
),
style: Theme.of(context).primaryTextTheme.headline2,
)),
body: SingleChildScrollView(
child: Padding(
Expand All @@ -46,7 +39,7 @@ class DevInfo extends StatelessWidget {
child: Text(
'ABOUT',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyText1!.copyWith(
style: Theme.of(context).primaryTextTheme.bodyText1!.copyWith(
fontSize: SizeConfig.safeBlockHorizontal! * 6,
fontWeight: FontWeight.w400,
),
Expand All @@ -59,7 +52,7 @@ class DevInfo extends StatelessWidget {
child: Text(
Strings.aboutText,
textAlign: TextAlign.left,
style: Theme.of(context).textTheme.bodyText1!.copyWith(
style: Theme.of(context).primaryTextTheme.bodyText1!.copyWith(
fontSize: SizeConfig.safeBlockHorizontal! * 4,
fontWeight: FontWeight.w400,
),
Expand All @@ -81,10 +74,13 @@ class DevInfo extends StatelessWidget {
child: Text(
'DEVELOPERS',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyText1!.copyWith(
fontSize: SizeConfig.safeBlockHorizontal! * 5.675,
fontWeight: FontWeight.w500,
color: kTextColourBlue),
style: Theme.of(context)
.primaryTextTheme
.headline3!
.copyWith(
fontSize: SizeConfig.safeBlockHorizontal! * 5.675,
fontWeight: FontWeight.w500,
color: kTextColourBlue),
),
),
),
Expand Down
Loading