Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #188

Merged
merged 3 commits into from
Nov 7, 2024
Merged

Dev #188

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/domain/controllers/dnd_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ abstract class DndController {

void init();

Future<void> enableDnd();
Future<void> enable();

Future<bool> isDnd();

Future<void> disable();
}
16 changes: 15 additions & 1 deletion lib/infrastructure/dnd_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class _DndRepository extends DndController {
void init() => supported = Platform.isAndroid;

@override
Future<void> enableDnd() async {
Future<void> enable() async {
if (!supported) {
return;
}
Expand All @@ -21,6 +21,20 @@ class _DndRepository extends DndController {
}
}

@override
Future<void> disable() async {
if (!supported) {
return;
}

if (await PermissionsController.instance
.isNotificationPolicyAccessGranted()) {
await FlutterDnd.setInterruptionFilter(
FlutterDnd.INTERRUPTION_FILTER_ALL,
);
}
}

@override
Future<bool> isDnd() async {
if (!supported) {
Expand Down
7 changes: 5 additions & 2 deletions lib/presentation/organisms/ready_for_session_organism.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import 'package:infinite_horizons/domain/objects/work_type_abstract.dart';
import 'package:infinite_horizons/presentation/atoms/atoms.dart';

class ReadyForSessionOrganism extends StatefulWidget {
const ReadyForSessionOrganism(
this.onComplete, {
const ReadyForSessionOrganism({
required this.onComplete,
this.onNextPressed,
this.response,
});

final VoidCallback onComplete;
final String? response;
final VoidCallback? onNextPressed;

@override
State<ReadyForSessionOrganism> createState() =>
Expand All @@ -24,6 +26,7 @@ class _ReadyForSessionOrganismState extends State<ReadyForSessionOrganism> {
bool confettiGotPlayed = false;

void onPressed() {
widget.onNextPressed?.call();
setState(() {
nextPressed = true;
});
Expand Down
14 changes: 9 additions & 5 deletions lib/presentation/organisms/timer_organism.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ class TimerOrganismState extends State<TimerOrganism> {
TimerState state = TimerStateManager.state;
bool renderSizedBox = false;

void onComplete() {
TimerStateManager.incrementState();
TimerStateManager.iterateOverTimerStates();
setCurrentState();
}

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -219,11 +225,9 @@ class TimerOrganismState extends State<TimerOrganism> {
initialValue: timePassed,
);
case TimerState.readyToStart:
return ReadyForSessionOrganism(() {
TimerStateManager.incrementState();
TimerStateManager.iterateOverTimerStates();
setCurrentState();
});
return ReadyForSessionOrganism(
onComplete: onComplete,
);
}
}

Expand Down
9 changes: 6 additions & 3 deletions lib/presentation/organisms/tips_organism.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ class _TipsOrganismState extends State<TipsOrganism> {
Icons.do_not_disturb_off_outlined,
onIcon: Icons.do_not_disturb_on_outlined,
onChange: (value) {
confettiController.play();
DndController.instance.enableDnd();
if (value) {
confettiController.play();
DndController.instance.enable();
return;
}
DndController.instance.disable();
},
initialValue: isDnd!,
trailing: IconButton(
Expand All @@ -134,7 +138,6 @@ class _TipsOrganismState extends State<TipsOrganism> {
),
icon: const Icon(Icons.arrow_forward),
),
lockOnToggleOn: true,
),
],
),
Expand Down
1 change: 1 addition & 0 deletions lib/presentation/pages/activity_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class _ActivityPageState extends State<ActivityPage>
Widget build(BuildContext context) {
return PopScope(
onPopInvokedWithResult: onWillPop,
canPop: false,
child: Scaffold(
body: PageView(
onPageChanged: (index) {
Expand Down
25 changes: 21 additions & 4 deletions lib/presentation/pages/intro_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,19 @@ class _IntroPageState extends State<IntroPage> {
final GlobalKey<IntroductionScreenState> _introKey =
GlobalKey<IntroductionScreenState>();

bool showBackButton = true;
bool showNextButton = true;
bool isFinish = false;
IntroState state = IntroState.tips;
final Duration selectionTransitionDelay = const Duration(milliseconds: 200);

void onNextPressed() {
isFinish = true;
setState(() {
showBackButton = false;
});
}

void onIntroPageChange(int n) {
state = IntroState.getStateByPageNumber(n);
bool showNextButtonTemp = true;
Expand All @@ -42,10 +51,15 @@ class _IntroPageState extends State<IntroPage> {

void nextPage() => _introKey.currentState?.next();

void onDone(BuildContext context) => Navigator.of(context)
void onDone() => Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => ActivityPage()));

void previousPage() => _introKey.currentState?.previous();
void previousPage() {
if (isFinish) {
return;
}
_introKey.currentState?.previous();
}

void onHorizontalDrag(DragEndDetails details) {
if (details.primaryVelocity == 0) {
Expand Down Expand Up @@ -120,10 +134,13 @@ class _IntroPageState extends State<IntroPage> {
}),
),
customPageViewModel(
bodyWidget: ReadyForSessionPage(() => onDone(context)),
bodyWidget: ReadyForSessionPage(
onDone: onDone,
onNextPressed: onNextPressed,
),
),
],
showBackButton: true,
showBackButton: showBackButton,
back: const Icon(Icons.arrow_back),
next: const Icon(Icons.arrow_forward),
scrollPhysics: const NeverScrollableScrollPhysics(),
Expand Down
13 changes: 9 additions & 4 deletions lib/presentation/pages/ready_for_session_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import 'package:infinite_horizons/presentation/molecules/molecules.dart';
import 'package:infinite_horizons/presentation/organisms/organisms.dart';

class ReadyForSessionPage extends StatelessWidget {
const ReadyForSessionPage(this.callback);
const ReadyForSessionPage({
required this.onDone,
required this.onNextPressed,
});

final VoidCallback callback;
final VoidCallback onNextPressed;
final VoidCallback onDone;

void handleCallback() {
VibrationController.instance.vibrate(VibrationType.light);
callback();
onDone();
}

@override
Expand Down Expand Up @@ -41,7 +45,8 @@ class ReadyForSessionPage extends StatelessWidget {
scaffold: false,
title: 'start_session',
child: ReadyForSessionOrganism(
handleCallback,
onComplete: handleCallback,
onNextPressed: onNextPressed,
response: text,
),
);
Expand Down
Loading