import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:tone_snap/modules/sidea/widgets/my_voice_item.dart';
import 'package:tone_snap/components/view_state_widget.dart';
import 'package:tone_snap/modules/sidea/my_voice/my_voice_controller.dart';

class MyVoiceView extends GetView<MyVoiceController> {
  const MyVoiceView({super.key});

  @override
  Widget build(BuildContext context) {
    Get.put(MyVoiceController());
    return Obx(() {
      return ViewStateWidget(
        viewState: controller.viewState.value,
        child: MediaQuery.removePadding(
          context: context,
          removeTop: true,
          child: Scrollbar(
            controller: controller.scrollController,
            child: ListView.builder(
              controller: controller.scrollController,
              itemCount: controller.voiceList.length,
              padding: EdgeInsets.symmetric(vertical: 16.h),
              itemBuilder: (context, index) {
                var item = controller.voiceList[index];
                return MyVoiceItem(
                  item: item,
                  onTapItem: () => controller.onTapItem(item),
                  onReName: () => controller.onTapReName(item),
                  onDelete: () => controller.onTapDelete(item),
                );
              },
            ),
          ),
        ),
      );
    });
  }
}
