import 'package:electronic_assistant/dialog/add_agenda_dialog.dart';
import 'package:electronic_assistant/popup/template_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';

import '../resource/string.gen.dart';
import 'common_popup.dart';

typedef AgendaPopupCallback = void Function(AgendaTimeType type);

enum AgendaTimeType { nearlyAWeek, nearlyTwoWeek, nearlyAMonth, customTime }

void showAgendaTimePopup(
    BuildContext context, Alignment alignment, AgendaTimeType? type,
    {AgendaPopupCallback? callback}) {
  showViewTargetPopup(context, alignment, offset: Offset(-24.w, 0), [
    createSelectItem(
        StringName.popupNearlyAWeek.tr, type == AgendaTimeType.nearlyAWeek,
        onItemClick: () {
      callback?.call(AgendaTimeType.nearlyAWeek);
      SmartDialog.dismiss();
    }),
    createPopupDivider(),
    createSelectItem(
        StringName.popupNearlyTwoWeek.tr, type == AgendaTimeType.nearlyTwoWeek,
        onItemClick: () {
      callback?.call(AgendaTimeType.nearlyTwoWeek);
      SmartDialog.dismiss();
    }),
    createPopupDivider(),
    createSelectItem(
        StringName.popupNearlyAMonth.tr, type == AgendaTimeType.nearlyAMonth,
        onItemClick: () {
      callback?.call(AgendaTimeType.nearlyAMonth);
      SmartDialog.dismiss();
    }),
    createPopupDivider(),
    createSelectItem(
        StringName.popupCustomTime.tr, type == AgendaTimeType.customTime,
        onItemClick: () {
      callback?.call(AgendaTimeType.customTime);
      SmartDialog.dismiss();
    }),
  ]);
}
