aboutsummaryrefslogtreecommitdiffstats
path: root/lib/presentation/screens/media/player_navigation.dart
blob: 70a9906094220b1410edf57fd391e31b86d68102 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import 'package:flutter_ics_homescreen/core/utils/helpers.dart';
import 'package:flutter_ics_homescreen/export.dart';
import 'media_nav_notifier.dart';

class PlayerNavigation extends ConsumerStatefulWidget {
  const PlayerNavigation({super.key, required this.onPressed});
  final Function onPressed;

  @override
  ConsumerState<PlayerNavigation> createState() => _PlayerNavigationState();
}

class _PlayerNavigationState extends ConsumerState<PlayerNavigation> {
  List<String> navItems = ["My Media", "FM", "AM", "XM"];
  Map<MediaNavState, String> navStateMap = {
    MediaNavState.media: "My Media",
    MediaNavState.fm: "FM",
    MediaNavState.am: "AM",
    MediaNavState.xm: "XM"
  };
  //String selectedNav = "My Media";

  @override
  Widget build(BuildContext context) {
    var navState = ref.watch(mediaNavStateProvider);
    var selectedNav = navStateMap[navState];

    return Row(
        children: navItems
            .map((e) => Expanded(
                    child: Container(
                  margin: const EdgeInsets.symmetric(horizontal: 2),
                  decoration: BoxDecoration(
                    gradient: LinearGradient(colors: [
                      selectedNav == e
                          ? AGLDemoColors.neonBlueColor
                          : AGLDemoColors.buttonFillEnabledColor,
                      AGLDemoColors.gradientBackgroundDarkColor
                    ], begin: Alignment.topCenter, end: Alignment.bottomCenter),
                    // color: selectedNav == e
                    //     ? AGLDemoColors.neonBlueColor
                    //     : AGLDemoColors.buttonFillEnabledColor,
                  ),
                  child: Material(
                    color: Colors.transparent,
                    child: InkWell(
                      onTap: () {
                        setState(() {
                          if (e == "My Media" || e == "FM") {
                            selectedNav = e;
                          }
                        });
                        if (e == "My Media" || e == "FM") {
                          for (MapEntry<MediaNavState, String> me
                              in navStateMap.entries) {
                            if (me.value == e) widget.onPressed(me.key);
                          }
                        }
                      },
                      child: Container(
                        padding: const EdgeInsets.symmetric(vertical: 7),
                        decoration: BoxDecoration(
                            border: Border(
                                left: selectedNav == e
                                    ? const BorderSide(color: Colors.white12)
                                    : BorderSide.none,
                                right: selectedNav == e
                                    ? const BorderSide(color: Colors.white12)
                                    : BorderSide.none,
                                top: BorderSide(
                                    color: selectedNav == e
                                        ? Colors.white
                                        : Colors.white24,
                                    width: selectedNav == e ? 2 : 1))),
                        child: Text(
                          e,
                          textAlign: TextAlign.center,
                          style: TextStyle(
                              fontSize: 26,
                              shadows: [
                                selectedNav == e
                                    ? Helpers.dropShadowRegular
                                    : Helpers.dropShadowBig
                              ],
                              color: selectedNav == e
                                  ? Colors.white
                                  : AGLDemoColors.periwinkleColor,
                              fontWeight: selectedNav == e
                                  ? FontWeight.w700
                                  : FontWeight.w500),
                        ),
                      ),
                    ),
                  ),
                )))
            .toList());
  }
}