Skip to content

Commit

Permalink
Small visual changes to the tab bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Granja5 committed Jan 20, 2025
1 parent db2085d commit 2f95f6c
Showing 1 changed file with 7 additions and 64 deletions.
71 changes: 7 additions & 64 deletions packages/uni_app/lib/view/academic_path/schedule_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,13 @@ class SchedulePageView extends StatefulWidget {
SchedulePageViewState createState() => SchedulePageViewState();
}

class SchedulePageViewState extends State<SchedulePageView>
with SingleTickerProviderStateMixin {
late TabController tabController;
class SchedulePageViewState extends State<SchedulePageView> {
late List<DateTime> reorderedDates;

@override
void initState() {
super.initState();
reorderedDates = _getReorderedWeekDates(widget.currentWeek.start);
final currentDayIndex = reorderedDates.indexWhere(
(date) =>
date.day == widget.currentWeek.start.day &&
date.month == widget.currentWeek.start.month &&
date.year == widget.currentWeek.start.year,
);
tabController = TabController(
vsync: this,
length: 7,
initialIndex: currentDayIndex >= 0 ? currentDayIndex : 0,
);
}

@override
void dispose() {
tabController.dispose();
super.dispose();
}

@override
Expand All @@ -99,37 +80,22 @@ class SchedulePageViewState extends State<SchedulePageView>
];

return List.generate(7, (index) {
final isSelected = tabController.index == index;
return Tab(
key: Key('schedule-page-tab-$index'),
height: 45,
height: 35,
child: SizedBox(
width: 35,
height: 40,
width: 26,
height: 35,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
toShortVersion(reorderedDaysOfTheWeek[index]),
style: TextStyle(
fontFamily: 'Roboto',
fontWeight: FontWeight.w400,
fontSize: 12,
color: isSelected
? const Color.fromRGBO(102, 9, 16, 1)
: const Color.fromRGBO(48, 48, 48, 1),
),
reorderedDaysOfTheWeek[index].substring(0, 3),
style: Theme.of(context).textTheme.bodySmall,
),
Text(
'${reorderedDates[index].day}',
style: TextStyle(
fontFamily: 'Roboto',
fontWeight: FontWeight.w400,
fontSize: 12,
color: isSelected
? const Color.fromRGBO(102, 9, 16, 1)
: const Color.fromRGBO(48, 48, 48, 1),
),
style: Theme.of(context).textTheme.bodySmall,
),
],
),
Expand All @@ -138,29 +104,6 @@ class SchedulePageViewState extends State<SchedulePageView>
});
}

String toShortVersion(String dayOfTheWeek) {
String shortVersion;
switch (dayOfTheWeek) {
case 'Monday':
shortVersion = 'Mon';
case 'Tuesday':
shortVersion = 'Tue';
case 'Wednesday':
shortVersion = 'Wed';
case 'Thursday':
shortVersion = 'Thu';
case 'Friday':
shortVersion = 'Fri';
case 'Saturday':
shortVersion = 'Sat';
case 'Sunday':
shortVersion = 'Sun';
default:
shortVersion = 'Blank';
}
return shortVersion;
}

List<DateTime> _getReorderedWeekDates(DateTime startOfWeek) {
final sunday =
startOfWeek.subtract(Duration(days: startOfWeek.weekday % 7));
Expand Down

0 comments on commit 2f95f6c

Please sign in to comment.