Skip to content

Commit

Permalink
code improvements and use less SizedBox widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
user5522 committed Dec 20, 2023
1 parent c8131ec commit 1e14b42
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 54 deletions.
26 changes: 12 additions & 14 deletions lib/components/subject_management/subject_configs/time_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,11 @@ class TimeConfig extends ConsumerWidget {
),
),
),
const SizedBox(
width: 10,
),
const Icon(Icons.arrow_forward),
const SizedBox(
width: 10,
const Padding(
padding: EdgeInsets.symmetric(
horizontal: 10,
),
child: Icon(Icons.arrow_forward),
),
ActionChip(
side: BorderSide.none,
Expand Down Expand Up @@ -153,15 +152,14 @@ class TimeConfig extends ConsumerWidget {
),
),
),
if (occupied == true)
const SizedBox(
width: 10,
if (occupied)
const Padding(
padding: EdgeInsets.only(left: 10),
child: Icon(
Icons.cancel,
color: Colors.redAccent,
),
),
if (occupied == true)
const Icon(
Icons.cancel,
color: Colors.redAccent,
)
],
);
}
Expand Down
23 changes: 10 additions & 13 deletions lib/components/subject_management/subject_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class SubjectScreen extends HookConsumerWidget {
onPressed: () {
if (formKey.currentState!.validate()) {
if (isSubjectNull) {
if (isOccupied == false) {
if (!isOccupied) {
state.addSubject(newSubject);
Navigator.pop(context, label.value);
} else {
Expand All @@ -150,7 +150,7 @@ class SubjectScreen extends HookConsumerWidget {
);
}
} else {
if (isOccupiedExceptSelf == false) {
if (!isOccupiedExceptSelf) {
state.updateSubject(subject!, newSubject);
Navigator.pop(context, label.value);
} else {
Expand Down Expand Up @@ -220,12 +220,9 @@ class SubjectScreen extends HookConsumerWidget {
),
],
),
const SizedBox(
height: 10,
),
ColorsConfig(color: color),
const SizedBox(
height: 10,
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: ColorsConfig(color: color),
),
TimeDayRotationWeekConfig(
day: day,
Expand All @@ -234,12 +231,12 @@ class SubjectScreen extends HookConsumerWidget {
endTime: endTime,
occupied: isSubjectNull ? isOccupied : isOccupiedExceptSelf,
),
const SizedBox(
height: 10,
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: NotesTile(
note: note,
),
),
NotesTile(
note: note,
)
],
),
),
Expand Down
18 changes: 8 additions & 10 deletions lib/components/widgets/day_view_subject_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class DayViewSubjectBuilder extends ConsumerWidget {
),
),
),
// SizedBox is for incase the label is too long
const SizedBox(
width: 20,
),
Expand Down Expand Up @@ -123,9 +124,6 @@ class DayViewSubjectBuilder extends ConsumerWidget {
size: 19,
color: subLabelsColor,
),
const SizedBox(
width: 10,
),
Expanded(
child: Text(
location.toString(),
Expand All @@ -143,13 +141,13 @@ class DayViewSubjectBuilder extends ConsumerWidget {
if (note != null && note.isNotEmpty)
Row(
children: [
Icon(
Icons.sticky_note_2_outlined,
size: 19,
color: subLabelsColor,
),
const SizedBox(
width: 10,
Padding(
padding: const EdgeInsets.only(right: 10),
child: Icon(
Icons.sticky_note_2_outlined,
size: 19,
color: subLabelsColor,
),
),
Expanded(
child: Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ class OverlappingSubjBuilder extends ConsumerWidget {
height: (startTimeHour - earlierStartTimeHour) * (tileHeight),
),
Padding(
padding: const EdgeInsets.all(outerPadding),
padding: const EdgeInsets.fromLTRB(
outerPadding,
outerPadding,
outerPadding,
outerPadding - 1,
),
child: InkWell(
onTap: () {
Navigator.push(
Expand Down Expand Up @@ -116,7 +121,7 @@ class OverlappingSubjBuilder extends ConsumerWidget {
width: 0,
),
),
width: ((tileWidth / 2) - .75) - (outerPadding * 2),
width: ((tileWidth / 2) - .75) - (outerPadding * 2.25),
height:
(((endTimeHour - startTimeHour) * (tileHeight)) - 1) -
(outerPadding * 2),
Expand Down
2 changes: 1 addition & 1 deletion lib/components/widgets/grid_view_subject_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class SubjectBuilder extends ConsumerWidget {
height: 5,
),
if ((location != null))
if (hideLocation == false)
if (!hideLocation)
if (!hideTransparentSubjects)
Text(
location.toString(),
Expand Down
24 changes: 12 additions & 12 deletions lib/components/widgets/list_tile_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ class ListItem extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
children: [
ListTile(
title: title,
subtitle: subtitle,
leading: leading,
onTap: () {
onTap;
},
shape: shape,
tileColor: Theme.of(context).colorScheme.surfaceVariant,
),
const SizedBox(
height: 2,
Padding(
padding: const EdgeInsets.only(bottom: 2),
child: ListTile(
title: title,
subtitle: subtitle,
leading: leading,
onTap: () {
onTap;
},
shape: shape,
tileColor: Theme.of(context).colorScheme.surfaceVariant,
),
),
],
);
Expand Down
2 changes: 1 addition & 1 deletion lib/components/widgets/navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Navigation extends HookConsumerWidget {
case 0:
return const TimetableScreen();
case 1:
return SettingsScreen();
return const SettingsScreen();
default:
return const TimetableScreen();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Timetable extends ConsumerWidget {
),
useMaterial3: true,
),
home: Navigation(),
home: const Navigation(),
);
},
);
Expand Down

0 comments on commit 1e14b42

Please sign in to comment.