1
+ // import 'package:flutter/material.dart';
2
+ // import 'package:get/get.dart';
3
+ //
4
+ // import '../controllers/dashboard_controller.dart';
5
+ //
6
+ // class DashboardView extends GetView<DashboardController> {
7
+ // const DashboardView({super.key});
8
+ //
9
+ // @override
10
+ // Widget build(BuildContext context) {
11
+ // return Scaffold(
12
+ // body: Center(
13
+ // child: Obx(
14
+ // () => Column(
15
+ // mainAxisSize: MainAxisSize.min,
16
+ // children: [
17
+ // const Text(
18
+ // 'DashboardView is working',
19
+ // style: TextStyle(fontSize: 20),
20
+ // ),
21
+ // Text('Time: ${controller.now.value.toString()}'),
22
+ // ],
23
+ // ),
24
+ // ),
25
+ // ),
26
+ // );
27
+ // }
28
+ // }
1
29
import 'package:flutter/material.dart' ;
2
30
import 'package:get/get.dart' ;
31
+ import 'package:firebase_remote_config/firebase_remote_config.dart' ;
3
32
33
+ import '../../../../services/remote_config.dart' ;
4
34
import '../controllers/dashboard_controller.dart' ;
5
35
6
36
class DashboardView extends GetView <DashboardController > {
@@ -9,20 +39,105 @@ class DashboardView extends GetView<DashboardController> {
9
39
@override
10
40
Widget build (BuildContext context) {
11
41
return Scaffold (
12
- body: Center (
13
- child: Obx (
14
- () => Column (
15
- mainAxisSize: MainAxisSize .min,
16
- children: [
17
- const Text (
18
- 'DashboardView is working' ,
19
- style: TextStyle (fontSize: 20 ),
20
- ),
21
- Text ('Time: ${controller .now .value .toString ()}' ),
22
- ],
42
+ appBar: AppBar (
43
+ title: const Text ('Dashboard' ),
44
+ centerTitle: true ,
45
+ actions: [
46
+ GetBuilder <DashboardController >(
47
+ builder: (controller) {
48
+ return FutureBuilder <bool >(
49
+ future: RemoteConfig .instance.then ((config) => config.showSearchBarOnTop ()),
50
+ builder: (context, snapshot) {
51
+ if (snapshot.connectionState == ConnectionState .waiting) {
52
+ return const Center (child: CircularProgressIndicator ());
53
+ } else if (snapshot.hasError || ! snapshot.data! ) {
54
+ return const SizedBox .shrink ();
55
+ } else {
56
+ return GetPlatform .isMobile
57
+ ? PopupMenuButton <String >(
58
+ onSelected: (value) {
59
+ if (value == 'toggleSearchBar' ) {
60
+ controller.toggleSearchBarVisibility ();
61
+ }
62
+ },
63
+ itemBuilder: (BuildContext context) {
64
+ return [
65
+ PopupMenuItem <String >(
66
+ value: 'toggleSearchBar' ,
67
+ child: Row (
68
+ children: [
69
+ const Icon (Icons .search),
70
+ const SizedBox (width: 8 ),
71
+ const Text ('Toggle Search Bar' ),
72
+ ],
73
+ ),
74
+ ),
75
+ ];
76
+ },
77
+ )
78
+ : const SizedBox .shrink ();
79
+ }
80
+ },
81
+ );
82
+ },
23
83
),
84
+ ],
85
+ ),
86
+ body: Obx (
87
+ () {
88
+ // Use the controller's state for search bar visibility
89
+ bool isSearchBarVisible = controller.isSearchBarVisible.value;
90
+
91
+ return FutureBuilder <bool >(
92
+ future: RemoteConfig .instance.then ((config) => config.showSearchBarOnTop ()),
93
+ builder: (context, snapshot) {
94
+ if (snapshot.connectionState == ConnectionState .waiting) {
95
+ return const Center (child: CircularProgressIndicator ());
96
+ } else if (snapshot.hasError) {
97
+ return Center (child: Text ('Error: ${snapshot .error }' ));
98
+ } else {
99
+ return Column (
100
+ mainAxisSize: MainAxisSize .min,
101
+ children: [
102
+ if (isSearchBarVisible)
103
+ Padding (
104
+ padding: const EdgeInsets .all (8.0 ),
105
+ child: _buildSearchBar (),
106
+ ),
107
+ Expanded (
108
+ child: Center (
109
+ child: Column (
110
+ mainAxisSize: MainAxisSize .min,
111
+ children: [
112
+ const Text (
113
+ 'DashboardView is working' ,
114
+ style: TextStyle (fontSize: 20 ),
115
+ ),
116
+ Text ('Time: ${controller .now .value .toString ()}' ),
117
+ ],
118
+ ),
119
+ ),
120
+ ),
121
+ ],
122
+ );
123
+ }
124
+ },
125
+ );
126
+ },
127
+ ),
128
+ );
129
+ }
130
+
131
+ Widget _buildSearchBar () {
132
+ return TextField (
133
+ decoration: InputDecoration (
134
+ hintText: 'Search...' ,
135
+ border: OutlineInputBorder (
136
+ borderRadius: BorderRadius .circular (10.0 ),
24
137
),
138
+ prefixIcon: Icon (Icons .search),
25
139
),
26
140
);
27
141
}
28
142
}
143
+
0 commit comments