import 'package:flutter/Material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:keyboard/base/base_controller.dart';
import 'package:keyboard/base/base_page.dart';
import 'package:get/get.dart';
import 'package:keyboard/module/auto_renewal/auto_renewal_controller.dart';
import 'package:keyboard/resource/assets.gen.dart';

import '../../resource/string.gen.dart';
import '../../router/app_pages.dart';
import '../../utils/styles.dart';
import '../../widget/commonAppBar.dart';

class AutoRenewalPage extends BasePage<AutoRenewalController> {
  const AutoRenewalPage({super.key});

  static start() {
    Get.toNamed(RoutePath.autoRenewal);
  }

  @override
  Color backgroundColor() {
    return const Color(0xFFF6F5FA);
  }

  @override
  bool immersive() {
    return true;
  }

  @override
  Widget buildBody(BuildContext context) {
    return Scaffold(
      backgroundColor: backgroundColor(),
      appBar: CommonAppBar(
        title: StringName.autoRenewalManagement,
        backgroundColor: () {
          return Colors.transparent;
        },
        onBack: () {
          controller.clickBack();
        },
      ),
      body: Obx(() {
        return SizedBox(
          width: double.infinity,
          child:
          controller.hasAutoRenewal.value
              ? _hasAutoRenewal()
              : _notAutoRenewal(),
        );
      }),
    );
  }

  Widget _notAutoRenewal() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        SizedBox(height: 200.h),
        Assets.images.iconAutoRenewalNotSign.image(width: 96.w, height: 96.w),
        Text(
          StringName.autoRenewalNoService,
          style: Styles.getTextStyleBlack204W400(14.sp),
        ),
      ],
    );
  }

  Widget _hasAutoRenewal() {
    return Container(
      margin: EdgeInsets.only(left: 16.w, right: 16.w),
      padding: EdgeInsets.only(left: 16.w, right: 10.w, top: 8.h, bottom: 8.h),
      decoration: ShapeDecoration(
        color: Colors.white,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(12.r),
        ),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(
            StringName.autoRenewalService,
            style: Styles.getTextStyleBlack204W400(14.sp),
          ),
          Material(
            color: Colors.transparent,
            child: InkWell(
              borderRadius: BorderRadius.circular(12.r),
              onTap: () {
                controller.clickUnSignAutoRenewal();
              },
              child: Container(
                padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h),
                decoration: ShapeDecoration(
                  shape: RoundedRectangleBorder(
                    side: BorderSide(
                        width: 1.w, color: const Color(0xFFD0D1D6)),
                    borderRadius: BorderRadius.circular(12.r),
                  ),
                ),
                child: Text(
                  StringName.autoRenewalItemButtonDesc,
                  style: Styles.getTextStyleBlack204W400(14.sp),
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          )

        ],
      ),
    );
  }
}
