// lib/pages/settings/settings_page.dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:gifunavi/pages/settings/settings_controller.dart';

class SettingsPage extends GetView<SettingsController> {
  const SettingsPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('設定'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              'timer_duration'.tr,
              style: const TextStyle(
                fontSize: 18,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(height: 8),
            Obx(
                  () => controller.autoReturnDisabled.value
                  ? Container()
                  : Slider(
                value: controller.timerDuration.value.inSeconds.toDouble(),
                min: 5,
                max: 30,
                divisions: 5,
                label: '${controller.timerDuration.value.inSeconds}秒',
                onChanged: (value) {
                  controller.updateTimerDuration(value.toInt());
                },
              ),
            ),
            const SizedBox(height: 8),
            const Text(
              'マップ操作がなければ自動的に現在地に復帰します。そのタイマー秒数を入れて下さい。チェックボックスをチェックすると、自動復帰は行われなくなります。',
              style: TextStyle(fontSize: 14),
            ),
            const SizedBox(height: 16),
            Obx(
                  () => CheckboxListTile(
                title: const Text('自動復帰なし'),
                value: controller.autoReturnDisabled.value,
                onChanged: (value) {
                  controller.setAutoReturnDisabled(value!);
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
