Commit f75dff10195e587ff1c78221a131141490a85cdd

Authored by 权海
1 parent ba1e6e73

feat(ui):修复自定义主题页不应该出现的弹窗

@@ -32,6 +32,7 @@ class CreateWatchThemeController extends GetxController { @@ -32,6 +32,7 @@ class CreateWatchThemeController extends GetxController {
32 final isSaving = false.obs; 32 final isSaving = false.obs;
33 final List<int> _imageTaskVersions = List<int>.filled(4, 0); 33 final List<int> _imageTaskVersions = List<int>.filled(4, 0);
34 bool _isClosed = false; 34 bool _isClosed = false;
  35 + bool _creationCompleted = false;
35 late final TextEditingController themeNameController; 36 late final TextEditingController themeNameController;
36 37
37 @override 38 @override
@@ -199,6 +200,9 @@ class CreateWatchThemeController extends GetxController { @@ -199,6 +200,9 @@ class CreateWatchThemeController extends GetxController {
199 } 200 }
200 201
201 Future<void> handleCreateBack() async { 202 Future<void> handleCreateBack() async {
  203 + if (_creationCompleted) {
  204 + return;
  205 + }
202 if (customThemeName.value.isEmpty && 206 if (customThemeName.value.isEmpty &&
203 !customImagePaths.any((path) => path != null && path.isNotEmpty)) { 207 !customImagePaths.any((path) => path != null && path.isNotEmpty)) {
204 Get.back(); 208 Get.back();
@@ -260,12 +264,16 @@ class CreateWatchThemeController extends GetxController { @@ -260,12 +264,16 @@ class CreateWatchThemeController extends GetxController {
260 } 264 }
261 265
262 final createdTheme = await _loadCreatedTheme(); 266 final createdTheme = await _loadCreatedTheme();
263 - await Get.offAndToNamed(  
264 - Routes.WATCH_THEME_CUSTOM_PREVIEW,  
265 - arguments: {  
266 - 'theme': createdTheme ?? _buildThemeItem(uploadedImageUrls),  
267 - }, 267 + _creationCompleted = true;
  268 + unawaited(
  269 + Get.offNamed(
  270 + Routes.WATCH_THEME_CUSTOM_PREVIEW,
  271 + arguments: {
  272 + 'theme': createdTheme ?? _buildThemeItem(uploadedImageUrls),
  273 + },
  274 + ),
268 ); 275 );
  276 + return;
269 } catch (_) { 277 } catch (_) {
270 AppToast.show('创建表盘失败,请重试'); 278 AppToast.show('创建表盘失败,请重试');
271 } finally { 279 } finally {
@@ -16,7 +16,11 @@ class CreateWatchThemeView extends GetView<CreateWatchThemeController> { @@ -16,7 +16,11 @@ class CreateWatchThemeView extends GetView<CreateWatchThemeController> {
16 final topPadding = MediaQuery.paddingOf(context).top + kToolbarHeight; 16 final topPadding = MediaQuery.paddingOf(context).top + kToolbarHeight;
17 return PopScope( 17 return PopScope(
18 canPop: false, 18 canPop: false,
19 - onPopInvokedWithResult: (_, __) => controller.handleCreateBack(), 19 + onPopInvokedWithResult: (didPop, _) {
  20 + if (!didPop) {
  21 + controller.handleCreateBack();
  22 + }
  23 + },
20 child: WatchThemeGradientScaffold( 24 child: WatchThemeGradientScaffold(
21 title: '创作主题', 25 title: '创作主题',
22 onBack: controller.handleCreateBack, 26 onBack: controller.handleCreateBack,