import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
import 'package:get/get.dart';
import 'package:making_school_asignment_app/common/const_text.dart';
import 'package:making_school_asignment_app/page/global_widget/my_text.dart';

// 协议富文本
class AgreementPage extends StatelessWidget {
  const AgreementPage({super.key});

  @override
  Widget build(BuildContext context) {
    AGREEMENT_KEY type = AGREEMENT_KEY.values.byName(Get.arguments['type']);
    AgreementClass agreement = AGREEMENT_MAP[type]!;
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).primaryColor,
        title: quickText(agreement.title, color: Colors.white),
      ),
      body: ListView(
        padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 8.h),
        children: [
          HtmlWidget(
            agreement.richText,
            textStyle: const TextStyle(color: Colors.black),
            // 禁用文本选择，避免触发剪切板访问
            renderMode: RenderMode.column,
            // 禁用所有交互
            onTapUrl: (url) => false,
            // 自定义样式，确保安全
            customStylesBuilder: (element) => <String, String>{},
          ),
        ],
      ),
    );
  }
}
