summaryrefslogtreecommitdiffstats
path: root/lib/presentation/common_widget/custom_top_bar.dart
blob: 52e1e58ff0bd88cdc362445bf405f3303c16d540 (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
import 'package:intl/intl.dart';

import '../../export.dart';

class CustomTopBar extends ConsumerStatefulWidget
    implements PreferredSizeWidget {
  const CustomTopBar({super.key});

  @override
  CustomTopBarState createState() => CustomTopBarState();

  @override
  Size get preferredSize => const Size.fromHeight(80);
}

class CustomTopBarState extends ConsumerState<CustomTopBar> {
  @override
  Widget build(BuildContext context) {
    final singnalsConnection =
        ref.watch(signalsProvider.select((sinals) => sinals));
    final userName =
        ref.watch(usersProvider.select((user) => user.selectedUser.name));
    DateFormat dateFormat = DateFormat('hh:mm a');
    final currentime = ref.watch(currentTimeProvider);

    return AppBar(
      elevation: 0,
      backgroundColor: Colors.transparent,
      //leadingWidth: 100,

      title: Stack(
        //mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Positioned.fill(
            child: Align(
              alignment: Alignment.centerLeft,
              child: Wrap(
                children: [
                  RichText(
                    text: TextSpan(
                      text: dateFormat.format(currentime),
                      style: const TextStyle(color: Colors.white, fontSize: 26),
                      children: <InlineSpan>[
                        const WidgetSpan(
                          child: SizedBox(width: 16), // 16px space
                        ),
                        TextSpan(
                          text: userName,
                          style: const TextStyle(fontWeight: FontWeight.bold),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ),
          Align(
            alignment: Alignment.center,
            child: Image.asset(
              'assets/topBarLogo.png',
              width: 659,
              height: 56,
            ),
          ),
          Positioned.fill(
            child: Align(
              alignment: Alignment.centerRight,
              child: Wrap(
                children: [
                  Icon(
                    singnalsConnection.isBluetoothConnected
                        ? Icons.bluetooth
                        : Icons.bluetooth_disabled,
                    size: 24,
                  ),
                  const SizedBox(
                    width: 24,
                  ),
                  const Icon(
                    Icons.signal_cellular_4_bar_outlined,
                    size: 24,
                  ),
                  const SizedBox(
                    width: 24,
                  ),
                  Icon(
                    singnalsConnection.isWifiConnected
                        ? Icons.wifi
                        : Icons.wifi_off,
                    size: 24,
                  ),
                ],
              ),
            ),
          ),
        ],
      ),

      // ),
    );
  }
}