import 'dart:async';

import 'package:fis_ui/index.dart';
import 'package:fis_ui/interface/interactive_container.dart';
import 'package:flutter/cupertino.dart';
import 'package:fis_i18n/i18n.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flyinsono/architecture/define.dart';
import 'package:flyinsono/pages/user/user_id_auth_apply/widgets/row_label.dart';
import 'package:flyinsono/pages/user/user_id_auth_apply/widgets/selected_labels.dart';
import 'package:fis_jsonrpc/services/liveConsultation.m.dart';
import 'package:flyinsono/pages/user/user_id_auth_apply/controller.dart';
import 'package:get/get.dart';

class SelectedSkilledAreaLable extends FStatefulWidget
    implements FInteractiveContainer {
  SelectedSkilledAreaLable(
      {this.pageName = 'SelectedRoleLable', required this.controller});

  final UserIdAuthApplyController controller;

  @override
  final String pageName;
  static Completer<List<String>?>? _completer;
  static Future<List<String>?>? open(controller, {title = ''}) async {
    _completer = Completer<List<String>?>();
    Get.to(
      () => SelectedSkilledAreaLable(controller: controller),
      preventDuplicates: false,
      transition: Transition.rightToLeftWithFade,
    );
    final result = await _completer!.future;
    _completer = null;
    return result;
  }

  @override
  FState<SelectedSkilledAreaLable> createState() =>
      _SelectedSkilledAreaLableState();
}

class _SelectedSkilledAreaLableState extends FState<SelectedSkilledAreaLable> {
  @override
  FWidget build(BuildContext context) {
    return FScaffold(
      appBar: FAppBar.simple(
        title: i18nBook.user.skilledArea.t,
        onBackClicked: () => Get.back(),
      ),
      body: _buildSelect(),
    );
  }

  FWidget _buildSelect() {
    return FColumn(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        //FText(i18nBook.user.skilledArea.t, style: TextStyle(fontSize: 16.sp)),
        FContainer(
          margin: EdgeInsets.only(top: 5.sp),
          child: FObx(() {
            if (widget.controller.state.applyState == ApplyStateEnum.NotApply ||
                widget.controller.state.inEditing)
              return RoleLableRow();
            else
              return SelectedLabels();
          }),
        ),
        FSizedBox(height: 15.sp),
      ],
    );
  }
}
