aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bottom_panel.dart
blob: f61c59d343d9fe5c1cc5c56d3362f5d6f0684eba (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
import 'package:async/async.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:jovial_svg/jovial_svg.dart';
import 'package:flutter_homescreen/volume_slider.dart';

final StackIndexProvider = StateProvider<int>((ref) => 0);

class BottomPanelWidget extends ConsumerStatefulWidget {
  final double height;
  final Color? color;

  BottomPanelWidget({Key? key, required this.height, required this.color})
      : super(key: key);

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

class _BottomPanelWidgetState extends ConsumerState<BottomPanelWidget> {
  final iconColor = const Color(0xff4ee6f5);
  late RestartableTimer timer;

  initState() {
    super.initState();
    timer = new RestartableTimer(Duration(seconds: 3), _timerExpired);
  }

  void _timerExpired() {
    ref.read(StackIndexProvider.notifier).state = 0;
    timer.cancel();
  }

  @override
  Widget build(BuildContext context) {
    final int index = ref.watch(StackIndexProvider);

    return SizedBox(
        height: widget.height,
        child: IndexedStack(index: index, children: <Widget>[
          GestureDetector(
            child: Container(
                color: widget.color,
                child: Align(
                    alignment: Alignment.center,
                    child: ScalableImageWidget.fromSISource(
                        si: ScalableImageSource.fromSvg(
                            rootBundle, 'images/Utility_Logo_Grey-01.svg')))),
            onTap: () {
              ref.read(StackIndexProvider.notifier).state = 1;
              timer.reset();
            },
          ),
          Container(
              color: widget.color,
              child: Padding(
                  padding: EdgeInsets.fromLTRB(24, 8, 24, 8),
                  child: Stack(children: [
                    Column(children: [
                      Center(
                          child: Text("Volume",
                              style: TextStyle(
                                  fontSize: 32, color: Colors.white))),
                      Spacer()
                    ]),
                    Row(children: [
                      Container(width: 24),
                      Text("0 %",
                          style: TextStyle(fontSize: 32, color: Colors.white)),
                      Expanded(
                          child: VolumeSlider(
                              thumbColor: Colors.white,
                              activeColor: iconColor,
                              inactiveColor: Colors.grey.shade600,
                              activityTimer: timer)),
                      Text("100 %",
                          style: TextStyle(fontSize: 32, color: Colors.white)),
                      Container(width: 24)
                    ]),
                  ])))
        ]));
  }
}