import 'package:fis_i18n/i18n.dart';
import 'package:fis_jsonrpc/rpc.dart';
import 'package:fis_ui/index.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class EntrySelectedItem extends FStatefulWidget implements FWidget {
  final ThesaurusItemDTO entryInfo;

  EntrySelectedItem(this.entryInfo);

  @override
  FState<FStatefulWidget> createState() {
    return EntrySelectedItemState();
  }
}

class EntrySelectedItemState extends FState<EntrySelectedItem> {
  final TextStyle _textStyle = TextStyle(fontSize: 16);
  final desController = TextEditingController();
  final summaryController = TextEditingController();
  @override
  FWidget build(BuildContext context) {
    return FScaffold(
      appBar: FAppBar.simple(
        title: i18nBook.remedical.vocDetails.t,
        onBackClicked: () {
          Get.back();
        },
      ),
      body: _buildEntrySelectedItemContentView(),
    );
  }

  FWidget _buildEntrySelectedItemContentView() {
    final entryInfo = widget.entryInfo;
    desController.text = entryInfo.thesaurusItemDescription ?? '';
    summaryController.text = entryInfo.thesaurusItemConclusion ?? '';

    return FWrap(
      children: [
        FContainer(
          margin: EdgeInsets.only(left: 15, bottom: 5, top: 20),
          child: FText(
            i18nBook.remedical.description.t,
            style: _textStyle,
          ),
        ),
        FContainer(
          margin: EdgeInsets.symmetric(horizontal: 15, vertical: 5),
          child: FTextField(
            controller: desController,
            maxLines: 8,
            readOnly: true,
            style: _textStyle,
            decoration: InputDecoration(
              border: OutlineInputBorder(
                borderSide: BorderSide(
                  color: Colors.black,
                ),
              ),
            ),
            onChanged: (v) {},
          ),
        ),
        FContainer(
          margin: EdgeInsets.only(left: 15, top: 20),
          child: FText(
            i18nBook.remedical.summary.t,
            style: _textStyle,
          ),
        ),
        FContainer(
          margin: EdgeInsets.symmetric(horizontal: 15, vertical: 15),
          child: FTextField(
            controller: summaryController,
            maxLines: 8,
            readOnly: true,
            style: _textStyle,
            decoration: InputDecoration(
              border: OutlineInputBorder(
                borderSide: BorderSide(
                  color: Colors.black,
                ),
              ),
            ),
            onChanged: (v) {},
          ),
        ),
      ],
    );
  }
}
