import 'package:get/get.dart';

import '../mixins/request_tool_mixin.dart';

/// getx 的GetxController的拓展 结合团队的编码习惯
/// 用法示例：
///
/// 1. 定义 State 类：
/// ``` dart
///   dart  class MyState {
///     final String name;
///     MyState(this.name);
///   }
/// ```
/// 2. 定义 Controller：
/// ``` dart
///   class MyController extends GetxControllerExpand<MyState> {
///     @override
///     MyState get state => MyState('hello');
///   }
/// ```
/// 3. 定义 View：
/// ``` dart
///   class MyView extends GetViewExpand<MyController, MyState> {
///     const MyView({super.key});
///
///     @override
///     Widget build(BuildContext context) {
///       return Text(state.name);
///     }
///   }
/// ```
abstract class GetViewExpand<T extends GetxControllerExpand<U>, U> extends GetView<T> {
  const GetViewExpand({super.key});

  U get state => controller.state;

  @override
  T get controller => GetInstance().find<T>(tag: tag);
}

abstract class GetxControllerExpand<U> extends GetxController with RequestToolMixin {
  U get state;
}
