mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 13:08:42 +00:00
fix tutorial gets open to often
This commit is contained in:
parent
7997bc2fa0
commit
33ab69b1b7
2 changed files with 90 additions and 85 deletions
|
|
@ -1,15 +1,10 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:mutex/mutex.dart';
|
|
||||||
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
|
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
|
||||||
import 'package:twonly/src/utils/misc.dart';
|
import 'package:twonly/src/utils/misc.dart';
|
||||||
import 'package:twonly/src/utils/storage.dart';
|
import 'package:twonly/src/utils/storage.dart';
|
||||||
|
|
||||||
final lockDisplayTutorial = Mutex();
|
|
||||||
|
|
||||||
Future showTutorial(BuildContext context, List<TargetFocus> targets) async {
|
Future showTutorial(BuildContext context, List<TargetFocus> targets) async {
|
||||||
await lockDisplayTutorial.protect(() async {
|
|
||||||
Completer completer = Completer();
|
Completer completer = Completer();
|
||||||
TutorialCoachMark(
|
TutorialCoachMark(
|
||||||
targets: targets,
|
targets: targets,
|
||||||
|
|
@ -42,7 +37,6 @@ Future showTutorial(BuildContext context, List<TargetFocus> targets) async {
|
||||||
).show(context: context);
|
).show(context: context);
|
||||||
|
|
||||||
await completer.future;
|
await completer.future;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> checkIfTutorialAlreadyShown(String tutorialId) async {
|
Future<bool> checkIfTutorialAlreadyShown(String tutorialId) async {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mutex/mutex.dart';
|
||||||
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
|
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
|
||||||
import 'package:twonly/src/utils/misc.dart';
|
import 'package:twonly/src/utils/misc.dart';
|
||||||
import 'package:twonly/src/views/tutorial/show_tutorial.dart';
|
import 'package:twonly/src/views/tutorial/show_tutorial.dart';
|
||||||
|
|
||||||
|
final lockDisplayTutorial = Mutex();
|
||||||
|
|
||||||
Future showChatListTutorialSearchOtherUsers(
|
Future showChatListTutorialSearchOtherUsers(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
GlobalKey searchForOtherUsers,
|
GlobalKey searchForOtherUsers,
|
||||||
) async {
|
) async {
|
||||||
|
await lockDisplayTutorial.protect(() async {
|
||||||
if (await checkIfTutorialAlreadyShown("chat_list:search_users")) {
|
if (await checkIfTutorialAlreadyShown("chat_list:search_users")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -19,12 +23,14 @@ Future showChatListTutorialSearchOtherUsers(
|
||||||
context.lang.tutorialChatListSearchUsersDesc,
|
context.lang.tutorialChatListSearchUsersDesc,
|
||||||
));
|
));
|
||||||
await showTutorial(context, targets);
|
await showTutorial(context, targets);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future showChatListTutorialContextMenu(
|
Future showChatListTutorialContextMenu(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
GlobalKey firstUserListItemKey,
|
GlobalKey firstUserListItemKey,
|
||||||
) async {
|
) async {
|
||||||
|
await lockDisplayTutorial.protect(() async {
|
||||||
if (await checkIfTutorialAlreadyShown("chat_list:context_menu")) {
|
if (await checkIfTutorialAlreadyShown("chat_list:context_menu")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -37,12 +43,14 @@ Future showChatListTutorialContextMenu(
|
||||||
context.lang.tutorialChatListContextMenuDesc,
|
context.lang.tutorialChatListContextMenuDesc,
|
||||||
));
|
));
|
||||||
await showTutorial(context, targets);
|
await showTutorial(context, targets);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future showVerifyShieldTutorial(
|
Future showVerifyShieldTutorial(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
GlobalKey firstUserListItemKey,
|
GlobalKey firstUserListItemKey,
|
||||||
) async {
|
) async {
|
||||||
|
await lockDisplayTutorial.protect(() async {
|
||||||
if (await checkIfTutorialAlreadyShown("chat_messages:verify_shield")) {
|
if (await checkIfTutorialAlreadyShown("chat_messages:verify_shield")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -55,12 +63,14 @@ Future showVerifyShieldTutorial(
|
||||||
context.lang.tutorialChatMessagesVerifyShieldDesc,
|
context.lang.tutorialChatMessagesVerifyShieldDesc,
|
||||||
));
|
));
|
||||||
await showTutorial(context, targets);
|
await showTutorial(context, targets);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future showReopenMediaFilesTutorial(
|
Future showReopenMediaFilesTutorial(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
GlobalKey firstUserListItemKey,
|
GlobalKey firstUserListItemKey,
|
||||||
) async {
|
) async {
|
||||||
|
await lockDisplayTutorial.protect(() async {
|
||||||
if (await checkIfTutorialAlreadyShown("chat_messages:reopen_message")) {
|
if (await checkIfTutorialAlreadyShown("chat_messages:reopen_message")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -73,4 +83,5 @@ Future showReopenMediaFilesTutorial(
|
||||||
context.lang.tutorialChatMessagesReopenMessageDesc,
|
context.lang.tutorialChatMessagesReopenMessageDesc,
|
||||||
));
|
));
|
||||||
await showTutorial(context, targets);
|
await showTutorial(context, targets);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue