-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f40fede
commit 4f2a2a4
Showing
16 changed files
with
357 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
String capitalize(String s) { | ||
return "${s[0].toUpperCase()}${s.substring(1).toLowerCase()}"; | ||
} | ||
|
||
String trimSeparators(String s) { | ||
final sWithoutNewLines = s.replaceAll('\n', ' '); | ||
|
||
final splitted = sWithoutNewLines.split(' ').where((e) => e.isNotEmpty); | ||
|
||
return splitted.map((e) => e.trim()).join(' '); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:intl/intl.dart'; | ||
import 'package:uneconly/common/model/short_group_info.dart'; | ||
import 'package:uneconly/common/utils/string_utils.dart'; | ||
import 'package:uneconly/feature/schedule/model/schedule.dart'; | ||
|
||
class ScheduleTransformer { | ||
String transformScheduleToString( | ||
Schedule schedule, | ||
ShortGroupInfo groupInfo, | ||
) { | ||
const space = ' '; | ||
const newLine = '\n'; | ||
String result = ''; | ||
|
||
final groupName = groupInfo.groupName; | ||
|
||
if (groupName != null) { | ||
result += groupName; | ||
result += newLine; | ||
} | ||
|
||
result += 'Неделя ${schedule.week}'; | ||
result += newLine; | ||
result += newLine; | ||
|
||
if (schedule.daySchedules.isEmpty) { | ||
result += 'Нет расписания на эту неделю'; | ||
result += newLine; | ||
} | ||
|
||
for (final daySchedule in schedule.daySchedules) { | ||
result += DateFormat('dd.MM.yyyy').format(daySchedule.day); | ||
result += space; | ||
result += DateFormat('EEE', 'ru').format(daySchedule.day); | ||
result += newLine; | ||
|
||
if (daySchedule.lessons.isEmpty) { | ||
result += 'Нет пар'; | ||
result += newLine; | ||
} | ||
|
||
for (final lesson in daySchedule.lessons) { | ||
result += | ||
'${DateFormat('HH:mm').format(lesson.start)} - ${DateFormat('HH:mm').format(lesson.end)}'; | ||
result += newLine; | ||
result += lesson.name; | ||
result += newLine; | ||
result += trimSeparators(lesson.location); | ||
result += newLine; | ||
} | ||
|
||
result += newLine; | ||
} | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
enum ScheduleAction { | ||
share, | ||
favorite; | ||
} | ||
|
||
class ScheduleActionConfig { | ||
final ScheduleAction action; | ||
final VoidCallback onPressed; | ||
final Widget child; | ||
|
||
ScheduleActionConfig( | ||
this.child, { | ||
required this.action, | ||
required this.onPressed, | ||
}); | ||
} | ||
|
||
class ScheduleActionsPopup extends StatelessWidget { | ||
final List<ScheduleActionConfig> actions; | ||
|
||
const ScheduleActionsPopup({ | ||
super.key, | ||
required this.actions, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return PopupMenuButton( | ||
popUpAnimationStyle: AnimationStyle( | ||
curve: Curves.easeIn, | ||
duration: const Duration(milliseconds: 300), | ||
), | ||
offset: const Offset(0, 40), | ||
onSelected: (value) { | ||
for (final action in actions) { | ||
if (action.action == value) { | ||
action.onPressed(); | ||
|
||
return; | ||
} | ||
} | ||
}, | ||
itemBuilder: (context) { | ||
return actions | ||
.map( | ||
(e) => PopupMenuItem( | ||
value: e.action, | ||
child: e.child, | ||
), | ||
) | ||
.toList(); | ||
}, | ||
); | ||
} | ||
} // _SchedulePageState |
Oops, something went wrong.