import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:vitalapp/pages/widgets/function_button.dart';
import 'controller.dart';

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

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(8),
      color: Colors.grey.shade200,
      alignment: Alignment.bottomLeft,
      child: Container(
        color: Colors.white,
        alignment: Alignment.center,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              "当前版本：${controller.state.version}",
              style: const TextStyle(color: Colors.black, fontSize: 18),
            ),
            const SizedBox(height: 20),
            ElevatedButton.icon(
              icon: const Icon(Icons.exit_to_app),
              label: const Text("退出登录"),
              onPressed: () {
                controller.logOut();
              },
            ),
          ],
        ),
      ),
    );
  }

  List<Widget> _buildEntranceList(BuildContext context) {
    final list = <Widget>[];
    list.add(FunctionButton(
      label: "签名设置",
      icon: _buildIcon(Icons.edit_document, context),
      // onTap: controller.gotoInfo,
    ));
    list.add(FunctionButton(
      label: "退出登录",
      icon: _buildIcon(Icons.exit_to_app, context),
      onTap: controller.logOut,
    ));
    return list;
  }

  Widget _buildImgIcon(String assetName) {
    return Image.asset(
      "assets/images/patient/$assetName",
      width: 100,
      height: 100,
      fit: BoxFit.contain,
    );
  }

  Widget _buildIcon(IconData iconData, BuildContext context) {
    return Icon(
      iconData,
      size: 100,
      color: Theme.of(context).primaryColor,
    );
  }
}
