home/main: starting soon
This commit is contained in:
parent
5a1c07b468
commit
44880f2979
@ -1 +1 @@
|
||||
Subproject commit 6c4dcbda41f832e3e0f61b8430a8cf7118feed3f
|
||||
Subproject commit d29c947552669c8531dba3aaf2f14052c0ae14f3
|
@ -11,7 +11,7 @@ class FirkaFonts {
|
||||
TextStyle H_16px_trimmed; // TODO: somehow implement this
|
||||
// the design has this trimmed to 130% line height
|
||||
|
||||
TextStyle B_16R; // TODO: Replace these with Figtree
|
||||
TextStyle B_16R;
|
||||
TextStyle B_16SB;
|
||||
|
||||
TextStyle B_14R;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:firka/helpers/extensions.dart';
|
||||
import 'package:firka/ui/phone/widgets/home_main_welcome.dart';
|
||||
import 'package:firka/ui/phone/widgets/home_main_starting_soon.dart';
|
||||
import 'package:firka/ui/widget/delayed_spinner.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@ -9,6 +9,7 @@ import '../../../../helpers/api/model/student.dart';
|
||||
import '../../../../helpers/api/model/timetable.dart';
|
||||
import '../../../../helpers/debug_helper.dart';
|
||||
import '../../../../main.dart';
|
||||
import '../../widgets/home_main_welcome.dart';
|
||||
|
||||
class HomeMainScreen extends StatefulWidget {
|
||||
final AppInitialization data;
|
||||
@ -67,8 +68,33 @@ class _HomeMainScreen extends State<HomeMainScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget startingSoon = SizedBox();
|
||||
if (lessons != null &&
|
||||
lessons!.isNotEmpty &&
|
||||
now.isBefore(lessons!.first.start)) {
|
||||
startingSoon = StartingSoonWidget(now, lessons!);
|
||||
}
|
||||
if (student != null && lessons != null) {
|
||||
return HomeMainWelcome(now, student!, lessons!);
|
||||
return Flexible(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 20.0,
|
||||
top: 24.0,
|
||||
right: 20.0,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
WelcomeWidget(now, student!, lessons!),
|
||||
SizedBox(height: 48),
|
||||
startingSoon,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
/*return Column(
|
||||
children: [HomeMainWelcome(now, student!, lessons!), SizedBox()],
|
||||
);*/
|
||||
} else {
|
||||
return DelayedSpinner();
|
||||
}
|
||||
|
102
firka/lib/ui/phone/widgets/home_main_starting_soon.dart
Normal file
102
firka/lib/ui/phone/widgets/home_main_starting_soon.dart
Normal file
@ -0,0 +1,102 @@
|
||||
import 'package:firka/helpers/ui/firka_card.dart';
|
||||
import 'package:firka/l10n/app_localizations.dart';
|
||||
import 'package:firka/ui/model/style.dart';
|
||||
import 'package:firka/ui/widget/counter_digit.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../helpers/api/model/timetable.dart';
|
||||
|
||||
class StartingSoonWidget extends StatelessWidget {
|
||||
final List<Lesson> lessons;
|
||||
final DateTime now;
|
||||
|
||||
const StartingSoonWidget(this.now, this.lessons, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var diff = lessons.first.start.difference(now);
|
||||
var hour = diff.inHours % 60;
|
||||
var min = diff.inMinutes % 60;
|
||||
var sec = diff.inSeconds % 60;
|
||||
|
||||
var hour_txt = hour == 1
|
||||
? AppLocalizations.of(context)!.starting_hour
|
||||
: AppLocalizations.of(context)!.starting_hour_plural;
|
||||
var min_txt = hour == 1
|
||||
? AppLocalizations.of(context)!.starting_min
|
||||
: AppLocalizations.of(context)!.starting_min_plural;
|
||||
var sec_txt = hour == 1
|
||||
? AppLocalizations.of(context)!.starting_sec
|
||||
: AppLocalizations.of(context)!.starting_sec_plural;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
FirkaCard(
|
||||
left: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(width: 6),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.starting_soon,
|
||||
style: appStyle.fonts.H_16px
|
||||
.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
CounterDigitWidget(
|
||||
hour.toString(),
|
||||
appStyle.fonts.H_16px
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
SizedBox(width: 2),
|
||||
Text(
|
||||
hour_txt,
|
||||
style: appStyle.fonts.B_16R
|
||||
.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
CounterDigitWidget(
|
||||
(min / 10).floor().toString(),
|
||||
appStyle.fonts.H_16px
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
CounterDigitWidget(
|
||||
((min % 10)).toString(),
|
||||
appStyle.fonts.H_16px
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
SizedBox(width: 2),
|
||||
Text(
|
||||
min_txt,
|
||||
style: appStyle.fonts.B_16R
|
||||
.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
CounterDigitWidget(
|
||||
(sec / 10).floor().toString(),
|
||||
appStyle.fonts.H_16px
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
CounterDigitWidget(
|
||||
((sec % 10)).toString(),
|
||||
appStyle.fonts.H_16px
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
SizedBox(width: 2),
|
||||
Text(
|
||||
sec_txt,
|
||||
style: appStyle.fonts.B_16R
|
||||
.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
right: [],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -8,12 +8,12 @@ import '../../../helpers/api/model/student.dart';
|
||||
import '../../../helpers/api/model/timetable.dart';
|
||||
import '../../model/style.dart';
|
||||
|
||||
class HomeMainWelcome extends StatelessWidget {
|
||||
class WelcomeWidget extends StatelessWidget {
|
||||
final Student student;
|
||||
final List<Lesson> lessons;
|
||||
final DateTime now;
|
||||
|
||||
const HomeMainWelcome(this.now, this.student, this.lessons, {super.key});
|
||||
const WelcomeWidget(this.now, this.student, this.lessons, {super.key});
|
||||
|
||||
getIconForCycle(Cycle dayCycle) {
|
||||
switch (dayCycle) {
|
||||
@ -92,28 +92,19 @@ class HomeMainWelcome extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
var dayCycle = now.getDayCycle();
|
||||
|
||||
return Flexible(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 16.0,
|
||||
right: 16.0,
|
||||
top: 24.0,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
getIconForCycle(dayCycle),
|
||||
const SizedBox(height: 16.0),
|
||||
Text(getTitle(context, dayCycle),
|
||||
style: appStyle.fonts.H_H2
|
||||
.copyWith(color: appStyle.colors.textPrimary)),
|
||||
const SizedBox(height: 2.0),
|
||||
Text(getSubtitle(context, dayCycle),
|
||||
style: appStyle.fonts.B_14R
|
||||
.copyWith(color: appStyle.colors.textSecondary)),
|
||||
],
|
||||
),
|
||||
),
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
getIconForCycle(dayCycle),
|
||||
const SizedBox(height: 16.0),
|
||||
Text(getTitle(context, dayCycle),
|
||||
style: appStyle.fonts.H_H2
|
||||
.copyWith(color: appStyle.colors.textPrimary)),
|
||||
const SizedBox(height: 2.0),
|
||||
Text(getSubtitle(context, dayCycle),
|
||||
style: appStyle.fonts.B_14R
|
||||
.copyWith(color: appStyle.colors.textSecondary)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
24
firka/lib/ui/widget/counter_digit.dart
Normal file
24
firka/lib/ui/widget/counter_digit.dart
Normal file
@ -0,0 +1,24 @@
|
||||
import 'package:firka/ui/model/style.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CounterDigitWidget extends StatelessWidget {
|
||||
final String c;
|
||||
final TextStyle? style;
|
||||
|
||||
const CounterDigitWidget(this.c, this.style, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
shadowColor: Colors.transparent,
|
||||
color: appStyle.colors.buttonSecondaryFill,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 8, right: 8, top: 4, bottom: 4),
|
||||
child: Text(
|
||||
c,
|
||||
style: style,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user