Skip to content

Commit 06cbcb3

Browse files
authored
fix: code refactored and minor bugs resolved (#94)
1 parent 0a82f4c commit 06cbcb3

13 files changed

+271
-340
lines changed

Diff for: assets/ieee.png

2.49 KB
Loading

Diff for: lib/main.dart

+6-7
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ class MyApp extends StatefulWidget {
3131
}
3232

3333
class _MyAppState extends State<MyApp> {
34-
3534
//set the saved theme to our device
3635

3736
Future<void> loadAppTheme() async {
3837
final String theme = await getSetting('theme');
39-
if(theme==null){
40-
setState(() {
41-
device.theme = 'Light';
42-
});
43-
}
38+
// if (theme == null) {
39+
// setState(() {
40+
// device.theme = 'Light';
41+
// });
42+
// }
4443
setState(() {
4544
device.theme = theme;
4645
});
@@ -65,7 +64,7 @@ class _MyAppState extends State<MyApp> {
6564
builder: (context, theme, _) {
6665
return MaterialApp(
6766
debugShowCheckedModeBanner: false,
68-
theme: device.theme=='Dark'? theme.darkTheme : theme.lightTheme,
67+
theme: device.theme == 'Dark' ? theme.darkTheme : theme.lightTheme,
6968
home: const SplashScreen(),
7069
routes: routes,
7170
);

Diff for: lib/providers/theme_provider.dart

+46-40
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ import 'package:flutter/material.dart';
22
import 'package:hacktoberfest_flutter/main.dart';
33
import 'package:hacktoberfest_flutter/shared/colors.dart';
44

5-
class ThemeProvider extends ChangeNotifier{
6-
7-
var lightTheme= ThemeData(
5+
class ThemeProvider extends ChangeNotifier {
6+
var lightTheme = ThemeData(
87
fontFamily: 'Poppins-Regular',
98
focusColor: hacktoberVioletLight,
109
indicatorColor: hacktoberViolet,
11-
highlightColor: Color(0xFFAA96DA),
12-
iconButtonTheme : IconButtonThemeData(
10+
highlightColor: const Color(0xFFAA96DA),
11+
iconButtonTheme: IconButtonThemeData(
1312
style: ButtonStyle(
1413
iconColor: MaterialStateProperty.all(Colors.black),
1514
),
1615
),
1716
appBarTheme: const AppBarTheme(
18-
backgroundColor: Colors.white,
17+
backgroundColor: Colors.white,
1918
),
2019
secondaryHeaderColor: Colors.black,
2120
primaryColor: Colors.white,
@@ -26,56 +25,60 @@ class ThemeProvider extends ChangeNotifier{
2625
labelColor: hacktoberViolet,
2726
indicatorColor: hacktoberViolet,
2827
labelStyle: const TextStyle(
29-
fontWeight: FontWeight.w600,fontSize: 16,
28+
fontWeight: FontWeight.w600,
29+
fontSize: 16,
3030
),
3131
unselectedLabelStyle: const TextStyle(
32-
fontWeight: FontWeight.w600,fontSize: 16,
32+
fontWeight: FontWeight.w600,
33+
fontSize: 16,
3334
),
3435
unselectedLabelColor: Colors.black,
3536
),
3637
inputDecorationTheme: InputDecorationTheme(
3738
suffixIconColor: Colors.black,
38-
labelStyle: const TextStyle(
39-
fontSize: 15,
40-
color: Colors.black,
41-
),
42-
helperStyle: const TextStyle(
43-
color: Colors.black,
44-
),
39+
labelStyle: const TextStyle(
40+
fontSize: 15,
41+
color: Colors.black,
42+
),
43+
helperStyle: const TextStyle(
44+
color: Colors.black,
45+
),
4546
enabledBorder: OutlineInputBorder(
4647
borderSide: BorderSide(
47-
color: hacktoberViolet,),
48+
color: hacktoberViolet,
49+
),
4850
borderRadius: const BorderRadius.all(Radius.circular(20)),
4951
),
5052
focusedBorder: OutlineInputBorder(
5153
borderSide: BorderSide(
52-
color: hacktoberViolet,),
53-
borderRadius:const BorderRadius.all(Radius.circular(20)),
54+
color: hacktoberViolet,
55+
),
56+
borderRadius: const BorderRadius.all(Radius.circular(20)),
5457
),
5558
),
5659
listTileTheme: const ListTileThemeData(
57-
textColor: Colors.black,
60+
textColor: Colors.black,
5861
),
5962
dialogTheme: const DialogTheme(
60-
titleTextStyle: TextStyle(
61-
color: Colors.black,
62-
fontWeight: FontWeight.w600,
63-
fontSize: 20,
64-
),
65-
backgroundColor: Colors.white,
63+
titleTextStyle: TextStyle(
64+
color: Colors.black,
65+
fontWeight: FontWeight.w600,
66+
fontSize: 20,
6667
),
68+
backgroundColor: Colors.white,
69+
),
6770
);
6871

6972
//global darkTheme for app
7073
var darkTheme = ThemeData(
7174
fontFamily: 'Poppins-Regular',
7275
focusColor: darkModeCardLight,
7376
indicatorColor: darkModeCard,
74-
highlightColor: Color(0xFF206993),
75-
iconButtonTheme : IconButtonThemeData(
76-
style: ButtonStyle(
77-
iconColor: MaterialStateProperty.all(const Color(0xff93C2DB)),
78-
),
77+
highlightColor: const Color(0xFF206993),
78+
iconButtonTheme: IconButtonThemeData(
79+
style: ButtonStyle(
80+
iconColor: MaterialStateProperty.all(const Color(0xff93C2DB)),
81+
),
7982
),
8083
appBarTheme: const AppBarTheme(
8184
backgroundColor: Color(0xff3C3C3C),
@@ -88,10 +91,12 @@ class ThemeProvider extends ChangeNotifier{
8891
labelColor: darkModeCard,
8992
indicatorColor: darkModeCard,
9093
labelStyle: const TextStyle(
91-
fontWeight: FontWeight.w600,fontSize: 16,
94+
fontWeight: FontWeight.w600,
95+
fontSize: 16,
9296
),
9397
unselectedLabelStyle: const TextStyle(
94-
fontWeight: FontWeight.w600,fontSize: 16,
98+
fontWeight: FontWeight.w600,
99+
fontSize: 16,
95100
),
96101
unselectedLabelColor: Colors.white,
97102
),
@@ -104,15 +109,17 @@ class ThemeProvider extends ChangeNotifier{
104109
helperStyle: const TextStyle(
105110
color: Colors.white,
106111
),
107-
enabledBorder: OutlineInputBorder(
112+
enabledBorder: OutlineInputBorder(
108113
borderSide: BorderSide(
109-
color: darkModeCard,),
110-
borderRadius:const BorderRadius.all(Radius.circular(20)),
114+
color: darkModeCard,
115+
),
116+
borderRadius: const BorderRadius.all(Radius.circular(20)),
111117
),
112118
focusedBorder: OutlineInputBorder(
113119
borderSide: BorderSide(
114-
color:darkModeCard,),
115-
borderRadius: const BorderRadius.all(Radius.circular(20)),
120+
color: darkModeCard,
121+
),
122+
borderRadius: const BorderRadius.all(Radius.circular(20)),
116123
),
117124
),
118125
listTileTheme: const ListTileThemeData(
@@ -129,9 +136,8 @@ class ThemeProvider extends ChangeNotifier{
129136
);
130137

131138
//changeTheme to set the theme chosen in settings page
132-
void changeTheme(bool isOn){
133-
device.theme=isOn?'Dark':'Light';
139+
void changeTheme(bool isOn) {
140+
device.theme = isOn ? 'Dark' : 'Light';
134141
notifyListeners();
135142
}
136-
137143
}

Diff for: lib/screens/bookmark.dart

+34-24
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import 'package:flutter/material.dart';
55
import 'package:flutter_slimy_card/flutter_slimy_card.dart';
66
import 'package:hacktoberfest_flutter/models/bookmarked_repo_model.dart';
77
import 'package:hacktoberfest_flutter/screens/contributors.dart';
8-
import 'package:hacktoberfest_flutter/shared/colors.dart';
8+
import 'package:hacktoberfest_flutter/widgets/custom_button.dart';
99
import 'package:shared_preferences/shared_preferences.dart';
1010
import 'package:url_launcher/url_launcher.dart';
1111

12-
import '../widgets/custom_button.dart';
13-
1412
class Bookmark extends StatefulWidget {
1513
const Bookmark({super.key});
1614
static String routename = 'Bookmark';
@@ -31,7 +29,8 @@ class _BookmarkState extends State<Bookmark> {
3129

3230
Future<List<BookmarkedRepository>> loadBookmarks() async {
3331
final SharedPreferences pref = await SharedPreferences.getInstance();
34-
final List<String> bookmarkStrings = pref.getStringList('bookmarking') ?? [];
32+
final List<String> bookmarkStrings =
33+
pref.getStringList('bookmarking') ?? [];
3534
final List<BookmarkedRepository> bookmarks = bookmarkStrings
3635
.map((item) => BookmarkedRepository.fromMap(json.decode(item)))
3736
.toList();
@@ -43,24 +42,23 @@ class _BookmarkState extends State<Bookmark> {
4342
int index,
4443
) async {
4544
final SharedPreferences prefs = await SharedPreferences.getInstance();
46-
final List<String> bookmarkStrings = prefs.getStringList('bookmarking') ?? [];
45+
final List<String> bookmarkStrings =
46+
prefs.getStringList('bookmarking') ?? [];
4747

4848
if (index >= 0) {
4949
bookmarkStrings.removeAt(index);
5050
prefs.setStringList('bookmarking', bookmarkStrings);
5151
}
52-
if(repository.fullName == 'IEEE-VIT/hackfest-flutter'){
52+
if (repository.fullName == 'IEEE-VIT/hackfest-flutter') {
5353
prefs.setBool('bookmarkedState', bookmarked);
5454
}
5555
setState(() {
5656
bookmarks = loadBookmarks();
5757
});
58-
5958
}
6059

6160
@override
6261
Widget build(BuildContext context) {
63-
6462
final deviceWidth = MediaQuery.of(context).size.width;
6563
return Scaffold(
6664
backgroundColor: Theme.of(context).primaryColor,
@@ -83,7 +81,7 @@ class _BookmarkState extends State<Bookmark> {
8381
padding: const EdgeInsets.all(8.0),
8482
child: FlutterSlimyCard(
8583
color: Theme.of(context).canvasColor,
86-
cardWidth: deviceWidth*0.88,
84+
cardWidth: deviceWidth * 0.88,
8785
topCardHeight: 150,
8886
bottomCardHeight: 250,
8987
borderRadius: 15,
@@ -94,9 +92,13 @@ class _BookmarkState extends State<Bookmark> {
9492
Container(
9593
alignment: Alignment.topRight,
9694
child: IconButton(
97-
onPressed: (){removeBookmark(repo, index);},
95+
onPressed: () {
96+
removeBookmark(repo, index);
97+
},
9898
icon: Icon(
99-
bookmarked?Icons.bookmark_outline:Icons.bookmark,
99+
bookmarked
100+
? Icons.bookmark_outline
101+
: Icons.bookmark,
100102
size: 40,
101103
color: Colors.white,
102104
),
@@ -127,20 +129,26 @@ class _BookmarkState extends State<Bookmark> {
127129
],
128130
),
129131
),
130-
const SizedBox(width: 20,),
132+
const SizedBox(
133+
width: 20,
134+
),
131135
Expanded(
132136
flex: 3,
133137
child: Text(
134138
'Owner: ${repo.owner}',
135-
style: const TextStyle(color: Colors.white,fontSize: 16,),
139+
style: const TextStyle(
140+
color: Colors.white,
141+
fontSize: 16,
142+
),
136143
overflow: TextOverflow.ellipsis,
137144
maxLines: 2,
138145
),
139146
),
140147
const SizedBox(height: 15),
141148
],
142149
),
143-
),],
150+
),
151+
],
144152
),
145153
),
146154
bottomCardWidget: SingleChildScrollView(
@@ -158,20 +166,22 @@ class _BookmarkState extends State<Bookmark> {
158166
textAlign: TextAlign.center,
159167
),
160168
const SizedBox(height: 15),
161-
Text(
162-
'Description: ${repo.description}',
163-
style: TextStyle(
164-
color: Colors.deepPurple[100],
165-
),
166-
maxLines: 4,
167-
overflow: TextOverflow.ellipsis,
168-
textAlign: TextAlign.center,
169+
Text(
170+
'Description: ${repo.description}',
171+
style: TextStyle(
172+
color: Colors.deepPurple[100],
169173
),
174+
maxLines: 4,
175+
overflow: TextOverflow.ellipsis,
176+
textAlign: TextAlign.center,
177+
),
170178
const SizedBox(height: 15),
171179
Padding(
172-
padding: const EdgeInsets.symmetric(horizontal: 20),
180+
padding:
181+
const EdgeInsets.symmetric(horizontal: 20),
173182
child: Row(
174-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
183+
mainAxisAlignment:
184+
MainAxisAlignment.spaceBetween,
175185
children: [
176186
CustomButton(
177187
height: 35,

0 commit comments

Comments
 (0)