import 'package:fis_i18n/i18n.dart';
import 'package:fis_ui/index.dart';
import 'package:fis_ui/interface/interactive_container.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/architecture/router/router.dart';
import 'package:flyinsono/views/desktop/appointment_consultation/index.dart';

class UpdatePatientSelectedInfo extends FStatefulWidget
    implements FInteractiveContainer {
  final List<FSelectModel> items;
  final String? selectedItem;
  final String? title;
  final void Function(String)? onSelectChanged;
  UpdatePatientSelectedInfo({
    required this.items,
    this.selectedItem,
    this.onSelectChanged,
    this.title,
  });

  @override
  String get pageName => 'UpdatePatientSelectedInfo';

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

class _UpdatePatientSelectedInfoState
    extends FState<UpdatePatientSelectedInfo> {
  @override
  FWidget build(BuildContext context) {
    return FScaffold(
      appBar: FAppBar(
        title: FText(
          widget.title ?? '',
        ),
        centerTitle: true,
        leading: FIconButton(
          name: "back",
          businessParent: widget,
          icon: FIcon(Icons.arrow_back_ios_new),
          onPressed: () {
            router.back();
          },
        ),
        elevation: 0,
        actions: [
          FTextButton(
              name: "confirm",
              businessParent: widget,
              child: FText(
                i18nBook.common.confirm.t,
                style: TextStyle(color: Colors.white, fontSize: 14),
              ),
              onPressed: () {
                router.back();
              }),
        ],
      ),
      body: FContainer(
        margin: EdgeInsets.symmetric(vertical: 20, horizontal: 15),
        child: FRow(
          children: [
            FText(widget.title ?? ''),
            FExpanded(
              child: FSizedBox(),
            ),
            FFromSelect(
              sourceList: widget.items,
              hintText: '',
              value: widget.selectedItem,
              onSelectChanged: (value, index) {
                widget.onSelectChanged?.call(value ?? '');
              },
            ),
          ],
        ),
      ),
    );
  }
}
