import 'package:flutter/widgets.dart';

class AdjustPanelConfig {
  final List<AdjustItemInfo> items;
  AdjustPanelConfig(this.items);
}

class UserUrmConfigInfo {
  final String code;
  final String configName;
  final bool isDefault;
  UserUrmConfigInfo({
    required this.code,
    required this.configName,
    required this.isDefault,
  });
}

class AdjustItemInfo {
  bool display = true;
  final String title;
  final String itemKey;
  final AdjustItemType itemType;
  AdjustItemInfo(this.title, this.itemType, {this.itemKey = ''});
}

// 多种类型的调节器
enum AdjustItemType {
  Type,
  Number,
  Switch,
  Button,
  FrameNumber,
  ButtonGroup,
  Preset,
}

// 类型选择器
class AdjustTypeItemInfo<T> extends AdjustItemInfo {
  List<T> types;
  Map<T, String> textMap;
  T currentValue;
  ValueChanged? onChanged;

  AdjustTypeItemInfo({
    required String title,
    required this.types,
    required this.textMap,
    required this.currentValue,
    this.onChanged,
    String key = '',
  }) : super(title, AdjustItemType.Type, itemKey: key);
}

// 数值调节器
class AdjustNumberItemInfo extends AdjustItemInfo {
  int min;
  int max;
  int currentValue;
  void Function(int)? onChanged;

  AdjustNumberItemInfo({
    required String title,
    required this.min,
    required this.max,
    required this.currentValue,
    this.onChanged,
    String key = '',
  }) : super(title, AdjustItemType.Number, itemKey: key);
}

// 开关
class AdjustSwitchItemInfo extends AdjustItemInfo {
  bool currentValue;
  void Function(bool)? onChanged;

  AdjustSwitchItemInfo({
    required String title,
    required this.currentValue,
    this.onChanged,
    String key = '',
  }) : super(title, AdjustItemType.Switch, itemKey: key);
}

// 按钮
class AdjustButtonItemInfo extends AdjustItemInfo {
  void Function()? onPressed;

  AdjustButtonItemInfo({
    required String title,
    this.onPressed,
    String key = '',
  }) : super(title, AdjustItemType.Button, itemKey: key);
}

class AdjustButtonGroupItemInfo extends AdjustItemInfo {
  List<AdjustButtonItemInfo> buttons;
  AdjustButtonGroupItemInfo({
    required String title,
    this.buttons = const [],
    String key = '',
  }) : super(title, AdjustItemType.ButtonGroup, itemKey: key);
}

// 数字调节器2
class AdjustNumberItemInfo2 extends AdjustItemInfo {
  int min;
  int max;
  int currentValue;
  void Function(int)? onChanged;

  AdjustNumberItemInfo2({
    required String title,
    this.onChanged,
    required this.min,
    required this.max,
    required this.currentValue,
    String key = '',
  }) : super(title, AdjustItemType.FrameNumber, itemKey: key);
}
