import 'package:flutter_translate/common/utils/bot_toast.dart';
import 'package:flutter_translate/common/utils/shared_util.dart';
import 'package:flutter_translate/pages/home/home_controller.dart';
import 'package:get/get.dart';

class ColorSettingController extends GetxController {
  List<int> colors = [
    0xff529F2D,
    0xff4488D3,
    0xff429488,
    0xffC73B4F,
  ];

  RxInt currentColor = 0xff529F2D.obs;

  @override
  void onInit() {
    super.onInit();
    int homeColor = HomeController.to.appColor.value;
    currentColor.value = homeColor;
  }

  void changeColor(int color) {
    currentColor.value = color;
  }

  void submit() {
    HomeController.to.appColor = currentColor;
    HomeController.to.update(["home_view"]);
    SharedUtil.getInstance().setData("appColor", currentColor.value);
    Get.back();
    toast("Change success");
  }
}
