import 'package:fis_i18n/i18n.dart';
import 'package:fis_ui/index.dart';
import 'package:fis_ui/base_define/page.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/architecture/define.dart';
import 'package:flyinsono/architecture/utils/prompt_box.dart';
import 'package:flyinsono/pages/user/user_profile/controller.dart';
import 'package:get/get.dart';

///用户信息修改弹窗框
class UserInfoDialog extends FisView<UserProfileController> implements FPage {
  UserInfoDialog({
    Key? key,
    required this.child,
  }) : super(key: key);
  @override
  final String pageName = 'UserInfoDialog';
  final FWidget child;

  @override
  FWidget build(BuildContext context) {
    return FSimpleDialog(
      title: FText(
        i18nBook.user.completeAccountInfo.t,
        style: TextStyle(
          color: Colors.white,
          fontSize: 18,
        ),
      ),
      backgroundColor: Color.fromRGBO(230, 230, 230, 1),
      children: [
        FContainer(
          width: 600,
          child: child,
        ),
      ],
      okString: i18nBook.common.confirm.t,
      cancelString: i18nBook.common.cancel.t,
      bottomButton: FContainer(
        alignment: Alignment.center,
        padding: EdgeInsets.symmetric(vertical: 15),
        child: FFlex(
          direction: Axis.horizontal,
          mainAxisSize: MainAxisSize.min,
          children: [
            FElevatedButton(
              name: "submitUserInfo",
              businessParent: this,
              onPressed: () {
                try {
                  controller.submitUserInfo();
                } catch (err) {
                  print(err);
                  PromptBox.toast(i18nBook.user.saveFailed.t);
                }
              },
              style: ButtonStyle(
                padding: MaterialStateProperty.all(
                  EdgeInsets.symmetric(
                    vertical: 15,
                    horizontal: 25,
                  ),
                ),
              ),
              child: FText(i18nBook.common.save4Btn.t),
            ),
            FSizedBox(
              width: 20,
            ),
            FOutlinedButton(
              name: "back",
              businessParent: this,
              onPressed: () => Get.back(),
              style: ButtonStyle(
                backgroundColor: MaterialStateProperty.all(
                  Colors.white,
                ),
                padding: MaterialStateProperty.all(
                  EdgeInsets.symmetric(vertical: 15, horizontal: 25),
                ),
              ),
              child: FText(
                i18nBook.common.cancel4Btn.t,
                style: TextStyle(
                  color: Color.fromRGBO(61, 146, 252, 1),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
