import 'package:fis_i18n/i18n.dart';
import 'package:fis_ui/index.dart';
import 'package:fis_ui/interface/interactive_container.dart';
import 'package:flyinsono/pages/schedule/calendar/calendar_page/mini_calendar/mini_calendar.dart';
import 'package:flyinsono/pages/schedule/calendar/calendar_page/my_calendar/my_calendar.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/pages/schedule/schedule_notification/schedule_notification_controller.dart';
import 'package:get/get.dart';

/// 日历视图左侧面板
class CalendarLeftPanel extends FStatefulWidget
    implements FInteractiveContainer {
  const CalendarLeftPanel({super.key});

  @override
  FState<CalendarLeftPanel> createState() => _CalendarLeftPanelState();

  @override
  String get pageName => "CalendarLeftPanel";
}

class _CalendarLeftPanelState extends FState<CalendarLeftPanel> {
  /// 固定的左侧宽度
  static const double _popupLayerMarginLeft = 240;

  /// 边框样式
  static const _borderSideStyle = BorderSide(
    color: Colors.black12,
    width: 1,
  );
  @override
  FWidget build(BuildContext context) {
    return FContainer(
      width: _popupLayerMarginLeft,
      decoration: const BoxDecoration(
        border: Border(right: _borderSideStyle),
      ),
      padding: const EdgeInsets.symmetric(horizontal: 10),
      child: FColumn(
        children: <FWidget>[
          /// TODO:[Gavin] 占位功能区，暂时屏蔽，待实现
          // _buildPanelTop(),
          const FSizedBox(height: 20),
          const MiniCalendar(),
          const FExpanded(
            child: MyCalendar(),
          ), // 撑开
          /// TODO:[Gavin] 占位功能区，暂时屏蔽，待实现
          // _buildPanelBottom(),
        ],
      ),
    );
  }

  /// 构建顶部【搜索日程、添加日程】
  FWidget _buildPanelTop() {
    return FSizedBox(
      height: 70,
      child: FContainer(
        padding: const EdgeInsets.symmetric(horizontal: 10),
        child: FRow(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <FWidget>[
            /// 单行输入框
            FExpanded(
              child: FSizedBox(
                height: 32,
                child: FTextField(
                  textAlignVertical: TextAlignVertical.bottom,
                  style: TextStyle(
                    height: null, // 迷惑???
                    color: Colors.black,
                    fontSize: 14,
                  ),
                  decoration: InputDecoration(
                    border: OutlineInputBorder(),
                    enabledBorder: OutlineInputBorder(
                      borderSide: BorderSide(color: Colors.black12, width: 1),
                    ),
                    focusedBorder: OutlineInputBorder(
                      borderSide: BorderSide(color: Colors.blue, width: 1),
                    ),
                    prefixIcon: Icon(
                      Icons.search,
                      size: 20,
                      color: Colors.black38,
                    ),
                    hintText: i18nBook.calendar.searchSchedule.t,
                    hintStyle: TextStyle(
                      color: Colors.black38,
                      fontSize: 14,
                    ),
                  ),
                ),
              ),
            ),
            const FSizedBox(width: 10),
            FSizedBox(
              width: 32,
              height: 32,
              child: FElevatedButton(
                name: "addSchedule",
                businessParent: widget,
                style: ButtonStyle(
                  padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
                      const EdgeInsets.all(0)),
                  shadowColor:
                      MaterialStateProperty.all<Color>(Colors.transparent),
                ),
                onPressed: (() {
                  ///FIXME: 临时测试用
                  ScheduleNotificationController notificationController =
                      Get.find<ScheduleNotificationController>();
                  notificationController.sendMockNotification();
                }),
                child: const FIcon(Icons.add),
              ),
            ),
          ],
        ),
      ),
    );
  }

  /// 构建底部【日历设置】
  FWidget _buildPanelBottom() {
    return FContainer(
      padding: const EdgeInsets.symmetric(vertical: 5),
      height: 50,
      decoration: const BoxDecoration(
        border: Border(top: _borderSideStyle),
        // color: const Color.fromARGB(90, 222, 59, 255),
      ),
      child: FFlex(
        direction: Axis.horizontal,
        children: [
          FExpanded(
            child: FSizedBox(
              height: double.infinity,
              child: FElevatedButton.icon(
                name: "calendarSetting",
                businessParent: widget,
                style: ButtonStyle(
                  // 按钮内容左对齐
                  alignment: Alignment.centerLeft,
                  backgroundColor:
                      MaterialStateProperty.all<Color>(Colors.transparent),
                  shadowColor:
                      MaterialStateProperty.all<Color>(Colors.transparent),
                  overlayColor: MaterialStateProperty.all<Color>(
                      const Color.fromARGB(255, 224, 226, 228)),
                  foregroundColor:
                      MaterialStateProperty.all<Color>(Colors.white),
                  surfaceTintColor:
                      MaterialStateProperty.all<Color>(Colors.white),
                ),
                icon: const Icon(
                  Icons.settings_outlined,
                  size: 20,
                  color: Colors.black54,
                ),
                label: Text(
                  i18nBook.calendar.calendarSetting.t,
                  style: TextStyle(color: Colors.black87),
                ),
                onPressed: () {
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(
                      duration: Duration(milliseconds: 500),
                      content: Text(i18nBook.calendar.todoPlaceholder.t),
                    ),
                  );
                },
              ),
            ),
          ),
        ],
      ),
    );
  }
  // Widget _build
}
