import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'agreement_read_logic.dart';
import 'agreement_read_state.dart';

class AgreementReadPage extends StatefulWidget {
  const AgreementReadPage({super.key});

  @override
  State<AgreementReadPage> createState() => AgreementReadPageState();
}

class AgreementReadPageState extends State<AgreementReadPage> {
  final AgreementReadLogic logic = Get.put(AgreementReadLogic());
  final AgreementReadState state = Get.find<AgreementReadLogic>().state;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          surfaceTintColor: Colors.white,
          elevation: 0,
          toolbarHeight: 0,
          systemOverlayStyle: const SystemUiOverlayStyle(
            statusBarColor: Colors.transparent,
            systemNavigationBarColor: Color(0xFF000000),
            systemNavigationBarIconBrightness: Brightness.light,
            statusBarIconBrightness: Brightness.dark,
            statusBarBrightness: Brightness.light,
          ),
          backgroundColor: Colors.white,
        ),
        body: Column(
          children: [
            /// 顶部布局
            Container(
              width: double.infinity,
              height: 44.h,
              alignment: Alignment.center,
              color: Colors.white,
              padding: const EdgeInsets.only(left: 16, right: 16),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  GestureDetector(
                    child: Container(
                      width: 50.w,
                      height: 44.h,
                      alignment: Alignment.centerLeft,
                      child: Image.asset(
                        'assets/images/agreement_back.png',
                      ),
                    ),
                    onTap: () {
                      Get.back();
                    },
                  ),
                  Text(
                    "隐私政策",
                    style:
                        TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w500),
                  ),
                  SizedBox(
                    width: 50.w,
                    height: 44.h,
                  )
                ],
              ),
            ),

            /// 中间布局
            Expanded(
                child: InAppWebView(
              initialUrlRequest:
                  URLRequest(url: WebUri("https://static.23544.com/WGShare-PrivacyPolicy.html")),
              initialSettings: InAppWebViewSettings(
                  transparentBackground: true,
                  safeBrowsingEnabled: true,
                  isFraudulentWebsiteWarningEnabled: true),
            )),
          ],
        ));
  }
}
