mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 11:18:41 +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,48 +1,42 @@
|
||||||
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,
|
colorShadow: context.color.primary,
|
||||||
colorShadow: context.color.primary,
|
textSkip: context.lang.ok,
|
||||||
textSkip: context.lang.ok,
|
alignSkip: Alignment.bottomCenter,
|
||||||
alignSkip: Alignment.bottomCenter,
|
textStyleSkip: TextStyle(
|
||||||
textStyleSkip: TextStyle(
|
color: Colors.black,
|
||||||
color: Colors.black,
|
fontWeight: FontWeight.bold,
|
||||||
fontWeight: FontWeight.bold,
|
fontSize: 20,
|
||||||
fontSize: 20,
|
),
|
||||||
),
|
onClickTarget: (target) {
|
||||||
onClickTarget: (target) {
|
print(target);
|
||||||
print(target);
|
},
|
||||||
},
|
onClickTargetWithTapPosition: (target, tapDetails) {
|
||||||
onClickTargetWithTapPosition: (target, tapDetails) {
|
print("target: $target");
|
||||||
print("target: $target");
|
print(
|
||||||
print(
|
"clicked at position local: ${tapDetails.localPosition} - global: ${tapDetails.globalPosition}");
|
||||||
"clicked at position local: ${tapDetails.localPosition} - global: ${tapDetails.globalPosition}");
|
},
|
||||||
},
|
onClickOverlay: (target) {
|
||||||
onClickOverlay: (target) {
|
print(target);
|
||||||
print(target);
|
},
|
||||||
},
|
onSkip: () {
|
||||||
onSkip: () {
|
completer.complete();
|
||||||
completer.complete();
|
return true;
|
||||||
return true;
|
},
|
||||||
},
|
onFinish: () {
|
||||||
onFinish: () {
|
completer.complete();
|
||||||
completer.complete();
|
},
|
||||||
},
|
).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,76 +1,87 @@
|
||||||
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 {
|
||||||
if (await checkIfTutorialAlreadyShown("chat_list:search_users")) {
|
await lockDisplayTutorial.protect(() async {
|
||||||
return;
|
if (await checkIfTutorialAlreadyShown("chat_list:search_users")) {
|
||||||
}
|
return;
|
||||||
if (!context.mounted) return;
|
}
|
||||||
List<TargetFocus> targets = [];
|
if (!context.mounted) return;
|
||||||
targets.add(getTargetFocus(
|
List<TargetFocus> targets = [];
|
||||||
context,
|
targets.add(getTargetFocus(
|
||||||
searchForOtherUsers,
|
context,
|
||||||
context.lang.tutorialChatListSearchUsersTitle,
|
searchForOtherUsers,
|
||||||
context.lang.tutorialChatListSearchUsersDesc,
|
context.lang.tutorialChatListSearchUsersTitle,
|
||||||
));
|
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 {
|
||||||
if (await checkIfTutorialAlreadyShown("chat_list:context_menu")) {
|
await lockDisplayTutorial.protect(() async {
|
||||||
return;
|
if (await checkIfTutorialAlreadyShown("chat_list:context_menu")) {
|
||||||
}
|
return;
|
||||||
if (!context.mounted) return;
|
}
|
||||||
List<TargetFocus> targets = [];
|
if (!context.mounted) return;
|
||||||
targets.add(getTargetFocus(
|
List<TargetFocus> targets = [];
|
||||||
context,
|
targets.add(getTargetFocus(
|
||||||
firstUserListItemKey,
|
context,
|
||||||
context.lang.tutorialChatListContextMenuTitle,
|
firstUserListItemKey,
|
||||||
context.lang.tutorialChatListContextMenuDesc,
|
context.lang.tutorialChatListContextMenuTitle,
|
||||||
));
|
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 {
|
||||||
if (await checkIfTutorialAlreadyShown("chat_messages:verify_shield")) {
|
await lockDisplayTutorial.protect(() async {
|
||||||
return;
|
if (await checkIfTutorialAlreadyShown("chat_messages:verify_shield")) {
|
||||||
}
|
return;
|
||||||
if (!context.mounted) return;
|
}
|
||||||
List<TargetFocus> targets = [];
|
if (!context.mounted) return;
|
||||||
targets.add(getTargetFocus(
|
List<TargetFocus> targets = [];
|
||||||
context,
|
targets.add(getTargetFocus(
|
||||||
firstUserListItemKey,
|
context,
|
||||||
context.lang.tutorialChatMessagesVerifyShieldTitle,
|
firstUserListItemKey,
|
||||||
context.lang.tutorialChatMessagesVerifyShieldDesc,
|
context.lang.tutorialChatMessagesVerifyShieldTitle,
|
||||||
));
|
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 {
|
||||||
if (await checkIfTutorialAlreadyShown("chat_messages:reopen_message")) {
|
await lockDisplayTutorial.protect(() async {
|
||||||
return;
|
if (await checkIfTutorialAlreadyShown("chat_messages:reopen_message")) {
|
||||||
}
|
return;
|
||||||
if (!context.mounted) return;
|
}
|
||||||
List<TargetFocus> targets = [];
|
if (!context.mounted) return;
|
||||||
targets.add(getTargetFocus(
|
List<TargetFocus> targets = [];
|
||||||
context,
|
targets.add(getTargetFocus(
|
||||||
firstUserListItemKey,
|
context,
|
||||||
context.lang.tutorialChatMessagesReopenMessageTitle,
|
firstUserListItemKey,
|
||||||
context.lang.tutorialChatMessagesReopenMessageDesc,
|
context.lang.tutorialChatMessagesReopenMessageTitle,
|
||||||
));
|
context.lang.tutorialChatMessagesReopenMessageDesc,
|
||||||
await showTutorial(context, targets);
|
));
|
||||||
|
await showTutorial(context, targets);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue