Skip to content

Commit

Permalink
add day schedule page
Browse files Browse the repository at this point in the history
  • Loading branch information
smart7even committed Sep 6, 2024
1 parent 324e189 commit 53a5e3f
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 7 deletions.
38 changes: 38 additions & 0 deletions lib/feature/schedule/widget/day_schedule_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:uneconly/common/utils/string_utils.dart';
import 'package:uneconly/feature/schedule/model/day_schedule.dart';
import 'package:uneconly/feature/schedule/widget/lesson_big_tile.dart';

/// {@template day_schedule_widget}
/// DayScheduleWidget widget
/// {@endtemplate}
class DaySchedulePage extends StatelessWidget {
final DaySchedule daySchedule;

/// {@macro day_schedule_widget}
const DaySchedulePage({super.key, required this.daySchedule});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
capitalize(
DateFormat('EEEE, d MMMM', 'ru').format(
daySchedule.day,
),
),
),
),
body: ListView.builder(
itemCount: daySchedule.lessons.length,
itemBuilder: (context, index) {
return LessonBigTile(
lesson: daySchedule.lessons[index],
);
},
),
);
}
}
108 changes: 108 additions & 0 deletions lib/feature/schedule/widget/lesson_big_tile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:uneconly/common/utils/string_utils.dart';
import 'package:uneconly/feature/schedule/model/lesson.dart';
import 'package:uneconly/feature/schedule/widget/lesson_property.dart';

/// {@template lesson_big_tile}
/// LessonBigTile widget
/// {@endtemplate}
class LessonBigTile extends StatelessWidget {
final Lesson lesson;

/// {@macro lesson_big_tile}
const LessonBigTile({
super.key,
required this.lesson,
});

Widget _buildLessonProperty(
BuildContext context,
IconData icon,
String text,
) {
return LessonProperty(
icon: icon,
text: text,
);
}

@override
Widget build(BuildContext context) {
final professor = lesson.professor;

return Container(
padding: const EdgeInsets.all(8),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: const EdgeInsets.only(right: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
DateFormat('HH:mm').format(
lesson.start,
),
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
RichText(
text: TextSpan(children: [
const TextSpan(
text: 'A',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
TextSpan(
text: DateFormat('HH:mm').format(
lesson.end,
),
style: const TextStyle(
color: Colors.black,
),
),
]),
),
],
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
lesson.name,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
const SizedBox(
height: 4,
),
_buildLessonProperty(
context,
Icons.location_on,
trimSeparators(lesson.location),
),
if (professor != null)
_buildLessonProperty(
context,
Icons.person,
professor,
),
const Divider(),
],
),
),
],
),
);
}
} // LessonBigTile
44 changes: 44 additions & 0 deletions lib/feature/schedule/widget/lesson_property.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';

class LessonProperty extends StatelessWidget {
final IconData icon;
final String text;

const LessonProperty({
super.key,
required this.icon,
required this.text,
});

@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.only(top: 2),
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
// color: Theme.of(context).colorScheme.secondary,
// rounded corners
borderRadius: BorderRadius.circular(4),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
icon,
size: 14,
// color: Colors.white,
),
const SizedBox(
width: 4,
),
Text(
text,
style: const TextStyle(
// color: Theme.of(context).colorScheme.onPrimary,
),
),
],
),
);
}
} // DayScheduleWidget
39 changes: 32 additions & 7 deletions lib/feature/schedule/widget/schedule_widget.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:l/l.dart';
Expand All @@ -7,6 +9,7 @@ import 'package:uneconly/common/routing/routes.dart';
import 'package:uneconly/common/utils/date_utils.dart';
import 'package:uneconly/common/utils/string_utils.dart';
import 'package:uneconly/feature/schedule/model/schedule.dart';
import 'package:uneconly/feature/schedule/widget/day_schedule_page.dart';
import 'package:uneconly/feature/schedule/widget/lesson_tile.dart';
import 'package:url_launcher/url_launcher.dart';

Expand Down Expand Up @@ -67,13 +70,35 @@ class ScheduleWidget extends StatelessWidget {
slivers.add(
SliverToBoxAdapter(
child: ListTile(
title: Text(
sectionTitle,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: difference == 0 ? Theme.of(context).primaryColor : null,
),
title: Row(
children: [
Expanded(
child: Text(
sectionTitle,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: difference == 0
? Theme.of(context).primaryColor
: null,
),
),
),
IconButton(
padding: EdgeInsets.zero,
constraints: const BoxConstraints(),
icon: const Icon(Icons.info_outlined),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return DaySchedulePage(daySchedule: daySchedule);
},
),
);
},
),
],
),
),
),
Expand Down

0 comments on commit 53a5e3f

Please sign in to comment.