import 'package:flutter/material.dart';

import 'package:f0ckapp/providers/media_provider.dart';

class FilterBar extends StatelessWidget {
  final MediaState mediaState;
  final MediaNotifier mediaNotifier;
  final ScrollController scrollController;
  
  const FilterBar({
    super.key,
    required this.mediaState,
    required this.mediaNotifier,
    required this.scrollController,
  });

  @override
  Widget build(BuildContext context) {
    return BottomAppBar(
      height: 50,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: [
          const Text('type: '),
          DropdownButton<String>(
            value: mediaTypes[mediaState.typeIndex],
            isDense: true,
            items: mediaTypes.map((String value) {
              return DropdownMenuItem<String>(
                value: value,
                child: Text(value),
              );
            }).toList(),
            onChanged: (String? newValue) {
              if (newValue != null) {
                mediaNotifier.setType(newValue);
                scrollController.jumpTo(0);
              }
            },
          ),
          const Text('mode: '),
          DropdownButton<String>(
            value: mediaModes[mediaState.modeIndex],
            isDense: true,
            items: mediaModes.map((String value) {
              return DropdownMenuItem<String>(
                value: value,
                child: Text(value),
              );
            }).toList(),
            onChanged: (String? newValue) {
              if (newValue != null) {
                mediaNotifier.setMode(mediaModes.indexOf(newValue));
                scrollController.jumpTo(0);
              }
            },
          ),
        ],
      ),
    );
  }
}
