/*
 * @Author       : WuWei
 * @LastEditors: wjc
 * @Date         : 2021-08-17 14:47:12
 * @LastEditTime: 2023-01-17 10:04:44
 * @Description  : Do not edit
 */
import 'package:app_package/app_package.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:task_package/src/view_models/work_instructions_store.dart';
import 'package:wisdom_cli/wisdom_cli.dart';
part 'index.g.dart';

///路由传递的参数
class WorkInstructionsDetailArguments {
  final String? id;
  WorkInstructionsDetailArguments({this.id});

  ///
  ///
  ///
  ///
  ///
  ///
  ///
//***以下为模板代码谨慎修改***
  factory WorkInstructionsDetailArguments.fromJson(Map<String, dynamic> json) {
    return _$WorkInstructionsDetailArgumentsFromJson(json);
  }
  factory WorkInstructionsDetailArguments.fromRouteArguments(
      BuildContext context) {
    return _$WorkInstructionsDetailArgumentsFromJson(
        (ModalRoute.of(context)?.settings.arguments ??
            new Map<String, dynamic>()) as Map<String, dynamic>);
  }
  Map<String, dynamic> toJson() =>
      _$WorkInstructionsDetailArgumentsToJson(this);
}

///
///
///
///
///
//***以下为模板代码谨慎修改***
class WorkInstructionsDetailPage extends StatelessWidget {
  const WorkInstructionsDetailPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(
            create: (_) => WorkInstructionsListStore(context)),
      ],
      child: _PageView(),
    );
  }
}

class _PageView extends StatefulWidget {
  _PageView({Key? key}) : super(key: key);

  @override
  __PageViewState createState() => __PageViewState();
}

class __PageViewState extends State<_PageView> {
  WorkInstructionsListStore get store =>
      Provider.of<WorkInstructionsListStore>(context, listen: false);
  @override
  void initState() {
    super.initState();
    store.onGetDetail();
  }

  @override
  Widget build(BuildContext context) {
    final colorScheme = WTheme.of(context).colorScheme;
    final String baseUrl = APPConfig.baseURL;
    return Scaffold(
      appBar: WAppBar(
        brightness: Brightness.light,
        iconTheme: IconThemeData(
          color: colorScheme.mainTitle,
          size: 19.pt,
        ),
        backgroundColor: Colors.white,
        title: Observer(builder: (_) {
          return WisText(store.instructionDetail?.name ?? '作业指导',
              size: 19.pt,
              weight: FontWeight.w600,
              color: colorScheme.mainTitle);
        }),
      ),
      body: SingleChildScrollView(
        child: Wisdom.column(
          color: Colors.white,
          margin: EdgeInsets.symmetric(vertical: 10.pt, horizontal: 15.pt),
          padding: EdgeInsets.all(15.pt),
          crossAxisAlignment: CrossAxisAlignment.stretch,
          borderRadius: BorderRadius.circular(10.pt),
          boxShadow: [
            BoxShadow(
              offset: Offset(0, 2.pt),
              color: Color(0x08000000),
              blurRadius: 10.pt,
              spreadRadius: 2.5.pt,
            ),
          ],
          children: [
            Wisdom.row(
              border: Border(
                bottom: BorderSide(
                  color: colorScheme.divider,
                  width: 0.5.pt,
                ),
              ),
              // margin: EdgeInsets.fromLTRB(15.pt, 25.pt, 15.pt, 20.pt),
              padding: EdgeInsets.only(bottom: 15.pt),
              children: [
                WisText(
                  '指导内容',
                  size: 18.pt,
                  weight: FontWeight.bold,
                ),
              ],
            ),
            Wisdom.column(
              children: [
                Observer(builder: (_) {
                  return HtmlWidget(
                    store.instructionDetail?.content != null &&
                            store.instructionDetail?.content != ''
                        ? store.instructionDetail?.content?.replaceAll(
                            RegExp(r'\"/9ad134a361f8d778'), '"$baseUrl') ?? ''
                        : '',
                  );
                }),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
