aboutsummaryrefslogtreecommitdiffstats
path: root/lib/presentation/screens/media_player/widgets/media_volume_bar.dart
blob: dd59ee0678f8128beef37f62ad9150f04b24da89 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import 'package:flutter_ics_homescreen/presentation/custom_icons/custom_icons.dart';

import '../../../../export.dart';
import '../../settings/settings_screens/audio_settings/widget/slider_widgets.dart';

class CustomVolumeSlider extends ConsumerStatefulWidget {
  const CustomVolumeSlider({
    super.key,
  });

  @override
  CustomVolumeSliderState createState() => CustomVolumeSliderState();
}

class CustomVolumeSliderState extends ConsumerState<CustomVolumeSlider> {
  void _increase() {
    _currentVal += 10;
    if (_currentVal > 100) {
      _currentVal = 100;
    }
    setState(() {
      ref.read(audioStateProvider.notifier).setVolume(_currentVal);
    });
  }

  void _dercrease() {
    _currentVal -= 10;
    if (_currentVal < 0) {
      _currentVal = 0;
    }
    setState(() {
      ref.read(audioStateProvider.notifier).setVolume(_currentVal);
    });
  }

  double _currentVal = 50;
  @override
  Widget build(BuildContext context) {
    final volumeValue =
        ref.watch(audioStateProvider.select((audio) => audio.volume));

    return Column(
      //crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Container(
          decoration: const ShapeDecoration(
            color: AGLDemoColors.buttonFillEnabledColor,
            shape: StadiumBorder(
                side: BorderSide(
              color: Color(0xFF5477D4),
              width: 0.5,
            )),
          ),
          height: 160,
          child: Row(
            children: [
              Padding(
                padding: const EdgeInsets.only(left: 20),
                child: Material(
                  color: Colors.transparent,
                  child: InkWell(
                      customBorder: const CircleBorder(),
                      onTap: () {
                        _dercrease();
                      },
                      child: const Padding(
                          padding: EdgeInsets.all(8.0),
                          child: Icon(
                            CustomIcons.vol_min,
                            color: AGLDemoColors.periwinkleColor,
                            size: 60,
                          ))),
                ),
              ),
              // Padding(
              //   padding: const EdgeInsets.only(left: 10.0),
              //   child: SizedBox(
              //     width: 50,
              //     child: IconButton(
              //         padding: EdgeInsets.zero,
              //         onPressed: () {
              //           _dercrease();
              //         },
              //         icon: const Icon(
              //           CustomIcons.vol_min,
              //           color: AGLDemoColors.periwinkleColor,
              //           size: 48,
              //         )),
              //   ),
              // ),
              Expanded(
                child: SliderTheme(
                  data: SliderThemeData(
                    overlayShape: SliderComponentShape.noOverlay,
                    valueIndicatorShape: SliderComponentShape.noOverlay,
                    activeTickMarkColor: Colors.transparent,
                    inactiveTickMarkColor: Colors.transparent,
                    inactiveTrackColor: AGLDemoColors.backgroundInsetColor,
                    thumbShape: const PolygonSliderThumb(
                        sliderValue: 3, thumbRadius: 23),
                    //trackHeight: 5,
                  ),
                  child: Slider(
                    divisions: 10,
                    min: 0,
                    max: 100,
                    value: volumeValue.toDouble(),
                    onChanged: (newValue) {
                      ref.read(audioStateProvider.notifier).setVolume(newValue);
                      _currentVal = newValue;
                    },
                  ),
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(right: 20),
                child: Material(
                  color: Colors.transparent,
                  child: InkWell(
                      customBorder: const CircleBorder(),
                      onTap: () {
                        _increase();
                      },
                      child: const Padding(
                          padding: EdgeInsets.all(8.0),
                          child: Icon(
                            CustomIcons.vol_max,
                            color: AGLDemoColors.periwinkleColor,
                            size: 60,
                          ))),
                ),
              ),
              // Padding(
              //   padding: const EdgeInsets.only(right: 10.0),
              //   child: SizedBox(
              //     width: 60,
              //     child: IconButton(
              //         padding: EdgeInsets.zero,
              //         onPressed: () {
              //           _increase();
              //         },
              //         icon: const Icon(
              //           CustomIcons.vol_max,
              //           color: AGLDemoColors.periwinkleColor,
              //           size: 48,
              //         )),
              //   ),
              // ),
            ],
          ),
        ),
      ],
    );
  }
}