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
- // }
29
1
import 'package:flutter/material.dart' ;
30
2
import 'package:get/get.dart' ;
31
- import 'package:firebase_remote_config/firebase_remote_config.dart' ;
32
3
33
- import '../../../../services/remote_config.dart' ;
34
4
import '../controllers/dashboard_controller.dart' ;
35
5
36
6
class DashboardView extends GetView <DashboardController > {
@@ -39,105 +9,20 @@ class DashboardView extends GetView<DashboardController> {
39
9
@override
40
10
Widget build (BuildContext context) {
41
11
return Scaffold (
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
- },
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
+ ],
83
23
),
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 ),
137
24
),
138
- prefixIcon: Icon (Icons .search),
139
25
),
140
26
);
141
27
}
142
28
}
143
-
0 commit comments