feat: Add splash screen and update routing to include it
This commit is contained in:
@@ -13,6 +13,7 @@ class _ScheduleScreenState extends State<ScheduleScreen> {
|
||||
DateTime currentWeek = DateTime.now();
|
||||
bool loading = false;
|
||||
List<dynamic> workdays = [];
|
||||
String? errorMsg;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -31,34 +32,48 @@ class _ScheduleScreenState extends State<ScheduleScreen> {
|
||||
IconButton(icon: Icon(Icons.chevron_right), onPressed: () { setState(() { currentWeek = currentWeek.add(Duration(days: 7)); }); fetchWorkdays(); }),
|
||||
]),
|
||||
SizedBox(height: 8),
|
||||
loading ? CircularProgressIndicator() : Expanded(
|
||||
child: LayoutBuilder(builder: (ctx, cons) {
|
||||
final cross = cons.maxWidth > 480 ? 4 : 2;
|
||||
return GridView.count(
|
||||
crossAxisCount: cross,
|
||||
childAspectRatio: 0.9,
|
||||
children: weekDays.map((day) {
|
||||
final formatted = DateFormat('yyyy-MM-dd').format(day);
|
||||
final wd = workdays.firstWhere((w) => (w['WorkDay'] ?? '').toString().substring(0,10) == formatted, orElse: () => null);
|
||||
String title = '';
|
||||
if (wd != null) {
|
||||
if (wd['Type'] == 1) title = 'PN';
|
||||
else if (wd['Type'] == 10) title = wd['text'] ?? '';
|
||||
}
|
||||
return Card(
|
||||
color: wd != null && wd['Type'] == 10 ? Color(0xFFA24BFA) : (wd != null && wd['Type'] == 1 ? Color(0xFFB388FF) : Color(0xFFede7f6)),
|
||||
child: Center(
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Text('${day.day}', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 6),
|
||||
Text(title, style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold)),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
})
|
||||
)
|
||||
if (errorMsg != null) ...[
|
||||
Text(errorMsg!, style: TextStyle(color: Colors.red)),
|
||||
SizedBox(height: 8),
|
||||
ElevatedButton(onPressed: fetchWorkdays, child: Text('Próbálja újra')),
|
||||
SizedBox(height: 8),
|
||||
],
|
||||
loading
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
)
|
||||
: Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: fetchWorkdays,
|
||||
child: LayoutBuilder(builder: (ctx, cons) {
|
||||
final cross = cons.maxWidth > 480 ? 4 : 2;
|
||||
return GridView.count(
|
||||
crossAxisCount: cross,
|
||||
childAspectRatio: 0.9,
|
||||
children: weekDays.map((day) {
|
||||
final formatted = DateFormat('yyyy-MM-dd').format(day);
|
||||
final wd = workdays.firstWhere((w) => (w['WorkDay'] ?? '').toString().substring(0,10) == formatted, orElse: () => null);
|
||||
String title = '';
|
||||
if (wd != null) {
|
||||
if (wd['Type'] == 1) title = 'PN';
|
||||
else if (wd['Type'] == 10) title = wd['text'] ?? '';
|
||||
}
|
||||
return Card(
|
||||
color: wd != null && wd['Type'] == 10 ? Color(0xFFA24BFA) : (wd != null && wd['Type'] == 1 ? Color(0xFFB388FF) : Color(0xFFede7f6)),
|
||||
child: Center(
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Text('${day.day}', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 6),
|
||||
Text(title, style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold)),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user