import 'package:cs_resources/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:auto_route/auto_route.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:router/ext/auto_router_extensions.dart';
import 'package:shared/utils/color_utils.dart';
import 'package:widgets/my_button.dart';
import 'package:widgets/my_text_view.dart';
import 'package:widgets/my_appbar.dart';
import 'package:cs_resources/theme/app_colors_theme.dart';
import 'package:widgets/utils/dark_theme_util.dart';
import '../../../router/page/services_page_router.dart';

@RoutePage()
class CleanOrderCancelSuccessPage extends HookConsumerWidget {
  const CleanOrderCancelSuccessPage({
    Key? key,
  }) : super(key: key);

  //启动当前页面
  static void startInstance({BuildContext? context}) {
    if (context != null) {
      context.router.replace(const CleanOrderCancelSuccessPageRoute());
    } else {
      appRouter.replace(const CleanOrderCancelSuccessPageRoute());
    }
  }

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    // final appConfigState = ref.watch(appConfigServiceProvider)

    useEffect(() {
      // 组件挂载时执行 - 执行接口请求
      // Future.microtask(() => vm.initPageData());
      return () {
        // 组件卸载时执行
        // Log.d("CleanOrderCancelSuccess_page 组件卸载时执行");
      };
    }, []);

    return Scaffold(
        appBar: MyAppBar.appBar(
          context,
          S.current.cancellation_of_order,
          backgroundColor: context.appColors.whiteBG,
        ),
        backgroundColor: DarkThemeUtil.multiColors(context, ColorUtils.string2Color('#F2F3F6'), darkColor: Colors.black)?? Colors.black,
        body: Center(
          child: Container(
            margin: const EdgeInsets.only(top: 50),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                MyTextView(
                  S.current.cancel_order_success,
                  fontSize: 15,
                  isFontRegular: true,
                  boxWidth: 270,
                  textAlign: TextAlign.center,
                  textColor: DarkThemeUtil.multiColors(context, ColorUtils.string2Color('#333333'), darkColor: Colors.white),
                  marginTop: 17,
                  marginBottom: 50,
                ),
                MyButton(
                  text: S.current.back_home,
                  onPressed: () {
                    // 回到首页
                    context.router.maybePop();
                  },
                  fontSize: 15,
                  fontWeight: FontWeight.w500,
                  textColor: context.appColors.textWhite,
                  backgroundColor: DarkThemeUtil.multiColors(context, context.appColors.textPrimary, darkColor: AppColorsTheme.color666666),
                  minHeight: 45,
                  minWidth: 310,
                )
              ],
            ),
          ),
        ));
  }
}
