💄 Optimize check in
This commit is contained in:
@@ -100,106 +100,117 @@ class CheckInWidget extends HookConsumerWidget {
|
|||||||
return Card(
|
return Card(
|
||||||
margin:
|
margin:
|
||||||
margin ?? EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 8),
|
margin ?? EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 8),
|
||||||
child: Column(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
spacing: 8,
|
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Expanded(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Row(
|
children: [
|
||||||
spacing: 8,
|
Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
spacing: 6,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
Icon(
|
children: [
|
||||||
switch (DateTime.now().weekday) {
|
Icon(
|
||||||
6 || 7 => Symbols.weekend,
|
switch (DateTime.now().weekday) {
|
||||||
_ => isAdult ? Symbols.work : Symbols.school,
|
6 || 7 => Symbols.weekend,
|
||||||
},
|
_ => isAdult ? Symbols.work : Symbols.school,
|
||||||
fill: 1,
|
},
|
||||||
size: 16,
|
fill: 1,
|
||||||
).padding(right: 2),
|
size: 16,
|
||||||
Text(DateFormat('EEE').format(DateTime.now()))
|
).padding(right: 2),
|
||||||
.fontSize(16)
|
Text(DateFormat('EEE').format(DateTime.now()))
|
||||||
.bold()
|
.fontSize(16)
|
||||||
.textColor(
|
.bold()
|
||||||
Theme.of(context).colorScheme.onSecondaryContainer,
|
.textColor(
|
||||||
),
|
Theme.of(context).colorScheme.onSecondaryContainer,
|
||||||
Text(DateFormat('MM/dd').format(DateTime.now()))
|
),
|
||||||
.fontSize(12)
|
Text(DateFormat('MM/dd').format(DateTime.now()))
|
||||||
.textColor(
|
.fontSize(16)
|
||||||
Theme.of(context).colorScheme.onSecondaryContainer,
|
.textColor(
|
||||||
)
|
Theme.of(context).colorScheme.onSecondaryContainer,
|
||||||
.padding(top: 2),
|
),
|
||||||
],
|
Expanded(
|
||||||
),
|
child: AnimatedSwitcher(
|
||||||
Row(
|
duration: const Duration(milliseconds: 300),
|
||||||
spacing: 5,
|
child: todayResult.when(
|
||||||
children: [
|
data: (result) {
|
||||||
Text('notableDayNext')
|
return Text(
|
||||||
.tr(args: [nextNotableDay.value?.localName ?? 'idk'])
|
result == null
|
||||||
.fontSize(12),
|
? 'checkInNone'
|
||||||
SlideCountdown(
|
: 'checkInResultLevel${result.level}',
|
||||||
decoration: const BoxDecoration(),
|
textAlign: TextAlign.start,
|
||||||
style: const TextStyle(fontSize: 12),
|
).tr().fontSize(15).bold();
|
||||||
separatorStyle: const TextStyle(fontSize: 12),
|
},
|
||||||
padding: EdgeInsets.zero,
|
loading:
|
||||||
duration: nextNotableDay.value?.date.difference(
|
() =>
|
||||||
DateTime.now(),
|
Text('checkInNone').tr().fontSize(15).bold(),
|
||||||
|
error:
|
||||||
|
(err, stack) =>
|
||||||
|
Text('error').tr().fontSize(15).bold(),
|
||||||
|
),
|
||||||
|
).alignment(Alignment.centerLeft),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
Row(
|
||||||
],
|
spacing: 5,
|
||||||
).padding(horizontal: 16, top: 8),
|
children: [
|
||||||
const Divider(height: 1),
|
Text('notableDayNext')
|
||||||
Row(
|
.tr(args: [nextNotableDay.value?.localName ?? 'idk'])
|
||||||
children: [
|
.fontSize(12),
|
||||||
Expanded(
|
if (nextNotableDay.value != null)
|
||||||
child: AnimatedSwitcher(
|
SlideCountdown(
|
||||||
|
decoration: const BoxDecoration(),
|
||||||
|
style: const TextStyle(fontSize: 12),
|
||||||
|
separatorStyle: const TextStyle(fontSize: 12),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
duration: nextNotableDay.value?.date.difference(
|
||||||
|
DateTime.now(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Gap(6),
|
||||||
|
AnimatedSwitcher(
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
child: todayResult.when(
|
child: todayResult.when(
|
||||||
data: (result) {
|
data: (result) {
|
||||||
if (result == null) return _CheckInNoneWidget();
|
if (result == null) {
|
||||||
return Column(
|
return Text('checkInNoneHint').tr().fontSize(11);
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
}
|
||||||
children: [
|
return Wrap(
|
||||||
Text(
|
alignment: WrapAlignment.start,
|
||||||
'checkInResultLevel${result.level}',
|
runAlignment: WrapAlignment.start,
|
||||||
).tr().fontSize(15).bold(),
|
children:
|
||||||
Wrap(
|
result.tips
|
||||||
children:
|
.map((e) {
|
||||||
result.tips
|
return Row(
|
||||||
.map((e) {
|
mainAxisSize: MainAxisSize.min,
|
||||||
return Row(
|
children: [
|
||||||
mainAxisSize: MainAxisSize.min,
|
Icon(
|
||||||
children: [
|
e.isPositive
|
||||||
Icon(
|
? Symbols.thumb_up
|
||||||
e.isPositive
|
: Symbols.thumb_down,
|
||||||
? Symbols.thumb_up
|
size: 12,
|
||||||
: Symbols.thumb_down,
|
),
|
||||||
size: 12,
|
const Gap(4),
|
||||||
),
|
Text(e.title).fontSize(11),
|
||||||
const Gap(4),
|
],
|
||||||
Text(e.title).fontSize(11),
|
);
|
||||||
],
|
})
|
||||||
);
|
.toList()
|
||||||
})
|
.expand(
|
||||||
.toList()
|
(widget) => [
|
||||||
.expand(
|
widget,
|
||||||
(widget) => [
|
Text(' · ').fontSize(11),
|
||||||
widget,
|
],
|
||||||
Text(' · ').fontSize(11),
|
)
|
||||||
],
|
.toList()
|
||||||
)
|
..removeLast(),
|
||||||
.toList()
|
|
||||||
..removeLast(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
loading: () => _CheckInNoneWidget(),
|
loading: () => Text('checkInNoneHint').tr().fontSize(11),
|
||||||
error:
|
error:
|
||||||
(err, stack) => Column(
|
(err, stack) => Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -209,53 +220,38 @@ class CheckInWidget extends HookConsumerWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
).alignment(Alignment.centerLeft),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton.outlined(
|
||||||
|
onPressed: () {
|
||||||
|
if (todayResult.valueOrNull == null) {
|
||||||
|
checkIn();
|
||||||
|
} else {
|
||||||
|
context.pushNamed(
|
||||||
|
'accountCalendar',
|
||||||
|
pathParameters: {'name': 'me'},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon: AnimatedSwitcher(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
child: todayResult.when(
|
||||||
|
data:
|
||||||
|
(result) => Icon(
|
||||||
|
result == null
|
||||||
|
? Symbols.local_fire_department
|
||||||
|
: Symbols.event,
|
||||||
|
key: ValueKey(result != null),
|
||||||
|
),
|
||||||
|
loading: () => const Icon(Symbols.refresh),
|
||||||
|
error: (_, _) => const Icon(Symbols.error),
|
||||||
),
|
),
|
||||||
IconButton.outlined(
|
),
|
||||||
onPressed: () {
|
),
|
||||||
if (todayResult.valueOrNull == null) {
|
|
||||||
checkIn();
|
|
||||||
} else {
|
|
||||||
context.pushNamed(
|
|
||||||
'accountCalendar',
|
|
||||||
pathParameters: {'name': 'me'},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
icon: AnimatedSwitcher(
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
child: todayResult.when(
|
|
||||||
data:
|
|
||||||
(result) => Icon(
|
|
||||||
result == null
|
|
||||||
? Symbols.local_fire_department
|
|
||||||
: Symbols.event,
|
|
||||||
key: ValueKey(result != null),
|
|
||||||
),
|
|
||||||
loading: () => const Icon(Symbols.refresh),
|
|
||||||
error: (_, _) => const Icon(Symbols.error),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
).padding(horizontal: 16, bottom: 12, top: 4),
|
|
||||||
],
|
],
|
||||||
),
|
).padding(horizontal: 16, vertical: 12),
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CheckInNoneWidget extends StatelessWidget {
|
|
||||||
const _CheckInNoneWidget();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
|
||||||
Text('checkInNone').tr().fontSize(15).bold(),
|
|
||||||
Text('checkInNoneHint').tr().fontSize(11),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user