import 'package:example/route/router.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:guru_utils/router/router.dart';
import 'package:guru_widgets/pages/settings/guru_settings_page.dart';
import 'package:guru_utils/settings/settings.dart';
import 'package:guru_utils/vibration/vibrate_model.dart';
import 'package:guru_utils/audio/audio_effector.dart';


import '../../data/settings/assistant_settings.dart';
import '../../generated/assets.dart';
import 'settings_controller.dart';

class SettingsPage extends GetWidget<SettingsController> {
  const SettingsPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final controller = Get.find<SettingsController>();
    final model = Get.find<SettingsController>().model;

    return GuruSettingsPage(
      items: [
        GroupSetting(
          title: "偏好",
          items: [
            SwitchSetting(
              enabledTitle: "声音",
              settingData: AssistantSettings.instance.soundEffect.toBoolData((p0) => false, (p0) => SoundEffect.on),
              onChanged: (value) {
                controller.switchSounds(value);
            }), 
            SwitchSetting(
              enabledTitle: "震动",
              settingData: AssistantSettings.instance.vibration.toBoolData((p0) => false, (p0) => VibrationState.on),
              onChanged: (value) {
                controller.switchVibration(value);
            }),
          ]
        )
      ],
      policyUrl: Uri.parse("www.test.com"),
      termsOfServiceUrl: Uri.parse("www.baidu.com"),
      onEnterDebugView: () {
        RouteCenter.instance.openPath(Routes.debug.path());
      },
      onTestTap: () {
        
      }
    );
  }
}
