watch_theme_controller.dart 1021 Bytes
import 'package:doublefeel_flutter/app/routes/app_pages.dart';
import 'package:get/get.dart';

import '../models/watch_theme_models.dart';

class WatchThemeController extends GetxController {
  final selectedOfficialIndex = 0.obs;
  final hasCustomThemes = false.obs;
  final isPremium = false.obs;

  @override
  void onInit() {
    super.onInit();
    final args = Get.arguments;
    if (args is Map) {
      hasCustomThemes.value = args['hasCustomThemes'] == true;
      isPremium.value = args['isPremium'] == true || hasCustomThemes.value;
    }
  }

  void executeBackLogic() {
    Get.back();
  }

  void selectOfficialTheme(int index) {
    selectedOfficialIndex.value = index;
    Get.toNamed(Routes.WATCH_THEME_PREVIEW, arguments: {
      'theme': officialThemes[index],
    });
  }

  void createCustomTheme() {
    Get.toNamed(Routes.WATCH_THEME_CREATE);
  }

  void previewCustomTheme(WatchThemeItem theme) {
    Get.toNamed(Routes.WATCH_THEME_CUSTOM_PREVIEW, arguments: {
      'theme': theme,
    });
  }
}