import 'package:flutter/material.dart';

import 'package:get/get.dart';

import 'package:f0ckapp/controller/mediacontroller.dart';

class FilterBar extends StatelessWidget {
  final ScrollController scrollController;

  const FilterBar({super.key, required this.scrollController});

  @override
  Widget build(BuildContext context) {
    final MediaController c = Get.find<MediaController>();

    return BottomAppBar(
      height: 50,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: [
          const Text('type: '),
          Obx(
            () => DropdownButton<String>(
              value: mediaTypes[c.typeIndex.value],
              isDense: true,
              items: mediaTypes.map((String value) {
                return DropdownMenuItem<String>(
                  value: value,
                  child: Text(value),
                );
              }).toList(),
              onChanged: (String? newValue) {
                if (newValue != null) {
                  c.setTypeIndex(mediaTypes.indexOf(newValue));
                  scrollController.jumpTo(0);
                }
              },
            ),
          ),
          const Text('mode: '),
          Obx(
            () => DropdownButton<String>(
              value: mediaModes[c.modeIndex.value],
              isDense: true,
              items: mediaModes.map((String value) {
                return DropdownMenuItem<String>(
                  value: value,
                  child: Text(value),
                );
              }).toList(),
              onChanged: (String? newValue) {
                if (newValue != null) {
                  c.setModeIndex(mediaModes.indexOf(newValue));
                  scrollController.jumpTo(0);
                }
              },
            ),
          ),
        ],
      ),
    );
  }
}
