Skip to content

Commit

Permalink
Merge pull request #4 from byonicku/nico
Browse files Browse the repository at this point in the history
  • Loading branch information
bootloopmaster636 authored Sep 22, 2023
2 parents 6531d50 + 34b5eca commit 352cc2d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
27 changes: 18 additions & 9 deletions lib/logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class TimerManager extends ChangeNotifier {
Duration _assistTimer =
const Duration(seconds: 0); // for the time where people can ask
bool _timerIsRunning = false;
bool _isSet = false;

String _title = "";

Color get currentAccent => _currentAccent;
Expand Down Expand Up @@ -58,6 +60,7 @@ class TimerManager extends ChangeNotifier {
hours: newAssistTimer!.hour,
minutes: newAssistTimer.minute,
seconds: 0);
_isSet = true;
notifyListeners();
}

Expand Down Expand Up @@ -115,19 +118,25 @@ class TimerManager extends ChangeNotifier {
print("Timer started");

Timer.periodic(const Duration(seconds: 1), (timer) {
if (_timerIsRunning &&
_displayTimer.inSeconds >= 0 &&
_assistTimer.inSeconds >= 0) {
_displayTimer = _displayTimer - const Duration(seconds: 1);
_assistTimer = _assistTimer - const Duration(seconds: 1);

changeAccent();
notifyListeners();
} else {
if (_displayTimer == const Duration(seconds: 0) || !_timerIsRunning) {
_displayTimer = const Duration(seconds: 0);
_assistTimer = const Duration(seconds: 0);
_endAt = const Duration(seconds: 0);
_isSet = false;

timer.cancel();
notifyListeners();

return;
}

if (_timerIsRunning) {
_displayTimer = _displayTimer - const Duration(seconds: 1);
_assistTimer -=
_isSet ? const Duration(seconds: 1) : const Duration(seconds: 0);

changeAccent();
notifyListeners();
}
});
}
Expand Down
28 changes: 20 additions & 8 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class MainScreen extends ConsumerWidget {
child: Container(
margin: EdgeInsets.fromLTRB(
40, MediaQuery.of(context).size.height * 0.08, 40, 0),
constraints: const BoxConstraints(maxWidth: 768),
constraints: const BoxConstraints(maxWidth: 960),
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
Expand Down Expand Up @@ -122,7 +122,7 @@ class MainScreen extends ConsumerWidget {
"${ref.watch(timerProvider).endAt.inHours.toString().padLeft(2, '0')} : "
"${ref.watch(timerProvider).endAt.inMinutes.remainder(60).toString().padLeft(2, '0')}",
style: const TextStyle(
fontSize: 29, fontWeight: FontWeight.w600),
fontSize: 28, fontWeight: FontWeight.w600),
),
],
),
Expand All @@ -136,7 +136,19 @@ class MainScreen extends ConsumerWidget {
children: [
FilledButton(
onPressed: () => ref.read(timerProvider).toggleTimer(),
child: const Text("Start/Freeze"),
child: Row(children: [
Icon(FontAwesomeIcons.play,
color: Theme.of(context).colorScheme.onPrimary,
size: 16),
const SizedBox(
width: 8,
),
Icon(
FontAwesomeIcons.pause,
color: Theme.of(context).colorScheme.onPrimary,
size: 16,
),
]),
),
const SizedBox(
width: 8,
Expand All @@ -146,7 +158,7 @@ class MainScreen extends ConsumerWidget {
context,
MaterialPageRoute(
builder: (context) => const SettingsView())),
child: const Text("Settings"),
child: const Icon(FontAwesomeIcons.gear, size: 16),
),
],
)
Expand All @@ -166,7 +178,7 @@ class MainScreen extends ConsumerWidget {
children: [
Icon(
FontAwesomeIcons.person,
size: 64,
size: 84,
color: Theme.of(context).colorScheme.onTertiaryContainer,
),
const SizedBox(
Expand All @@ -178,13 +190,13 @@ class MainScreen extends ConsumerWidget {
style: TextStyle(
color:
Theme.of(context).colorScheme.onTertiaryContainer,
fontSize: 20),
fontSize: 28),
children: [
TextSpan(
text:
"${ref.watch(timerProvider).assistTimer.inMinutes.toString().padLeft(2, '0')} menit ${ref.watch(timerProvider).assistTimer.inSeconds.remainder(60).toString().padLeft(2, '0')} detik",
style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 28)),
fontWeight: FontWeight.bold, fontSize: 36)),
],
),
)
Expand Down Expand Up @@ -219,7 +231,7 @@ class DisplayTimer extends ConsumerWidget {
"${ref.watch(timerProvider).displayTimer.inSeconds.remainder(60).toString().padLeft(2, '0')}",
overflow: TextOverflow.fade,
maxLines: 1,
style: const TextStyle(fontSize: 96, fontWeight: FontWeight.bold),
style: const TextStyle(fontSize: 128, fontWeight: FontWeight.bold),
);
}
}

0 comments on commit 352cc2d

Please sign in to comment.