Browse Source

union sprint 1 carlos

Oniel Mendez 3 years ago
parent
commit
f7c056870e

+ 5
- 2
fast_med_flutter/lib/main.dart View File

@@ -7,6 +7,7 @@ import 'package:fast_med_flutter/routes/register.dart';
7 7
 import 'package:fast_med_flutter/routes/welcome.dart';
8 8
 import 'package:fast_med_flutter/routes/album.dart';
9 9
 import 'package:flutter/material.dart';
10
+import 'package:fast_med_flutter/routes/especialidades.dart';
10 11
 
11 12
 void main() => runApp(MaterialApp(
12 13
     initialRoute: '/home',
@@ -17,7 +18,9 @@ void main() => runApp(MaterialApp(
17 18
       '/calendario': (context) => Calendario(),
18 19
       '/welcome': (context) => WelcomePage(),
19 20
       '/register': (context) => RegisterPage(),
20
-          '/MyApp': (context) => MyApp(),
21
-          '/album': (context) => album(),
21
+      '/MyApp': (context) => MyApp(),
22
+      '/album': (context) => album(),
23
+      '/especialidades': (context) => especialidades(),
24
+
22 25
     }
23 26
 ));

+ 109
- 0
fast_med_flutter/lib/routes/especialidades.dart View File

@@ -0,0 +1,109 @@
1
+import 'package:flutter/material.dart';
2
+import 'dart:convert';
3
+import 'package:json_table/json_table.dart';
4
+
5
+class SimpleTable extends StatefulWidget {
6
+  @override
7
+  _SimpleTableState createState() => _SimpleTableState();
8
+}
9
+
10
+class _SimpleTableState extends State<SimpleTable> {
11
+  final String jsonSample =
12
+      '[{"id":"0","name":"Dr.Collazo","Oficina":"A","Phone":"787-522-0123","Espe":"Dentist"},{"id":"1","name":"Dr.Lelolelo","Oficina":"B","Phone":"787-533-4567","Espe":"Dentist"},{"id":"2","name":"Dr.Pepo","Oficina":"C","Phone":"787-544-8910","Espe":"otorrinolaringologo"}]';
13
+  bool toggle = true;
14
+
15
+  @override
16
+  Widget build(BuildContext context) {
17
+    var json = jsonDecode(jsonSample);
18
+    return Scaffold(
19
+      body: Container(
20
+        padding: EdgeInsets.all(16.0),
21
+        child: toggle
22
+            ? Column(
23
+          children: [
24
+            JsonTable(
25
+              json,
26
+              showColumnToggle: true,
27
+              tableHeaderBuilder: (String header) {
28
+                return Container(
29
+                  padding: EdgeInsets.symmetric(
30
+                      horizontal: 8.0, vertical: 4.0),
31
+                  decoration: BoxDecoration(
32
+                      border: Border.all(width: 0.5),
33
+                      color: Colors.grey[300]),
34
+                  child: Text(
35
+                    header,
36
+                    textAlign: TextAlign.center,
37
+                    style: Theme.of(context).textTheme.display1.copyWith(
38
+                        fontWeight: FontWeight.w700,
39
+                        fontSize: 14.0,
40
+                        color: Colors.black87),
41
+                  ),
42
+                );
43
+              },
44
+              tableCellBuilder: (value) {
45
+                return Container(
46
+                  padding: EdgeInsets.symmetric(
47
+                      horizontal: 4.0, vertical: 2.0),
48
+                  decoration: BoxDecoration(
49
+                      border: Border.all(
50
+                          width: 0.5,
51
+                          color: Colors.grey.withOpacity(0.5))),
52
+                  child: Text(
53
+                    value,
54
+                    textAlign: TextAlign.center,
55
+                    style: Theme.of(context).textTheme.display1.copyWith(
56
+                        fontSize: 14.0, color: Colors.grey[900]),
57
+                  ),
58
+                );
59
+              },
60
+              allowRowHighlight: true,
61
+              rowHighlightColor: Colors.yellow[500].withOpacity(0.7),
62
+              paginationRowCount: 20,
63
+            ),
64
+            SizedBox(
65
+              height: 20.0,
66
+            ),
67
+            Text("Tabla Oficinas")
68
+          ],
69
+        )
70
+            : Center(
71
+          child: Text(getPrettyJSONString(jsonSample)),
72
+        ),
73
+      ),
74
+      floatingActionButton: FloatingActionButton(
75
+          child: Icon(Icons.grid_on),
76
+          onPressed: () {
77
+            setState(
78
+                  () {
79
+                toggle = !toggle;
80
+              },
81
+            );
82
+          }),
83
+    );
84
+  }
85
+
86
+  String getPrettyJSONString(jsonObject) {
87
+    JsonEncoder encoder = new JsonEncoder.withIndent('  ');
88
+    String jsonString = encoder.convert(json.decode(jsonObject));
89
+    return jsonString;
90
+  }
91
+}
92
+
93
+void main() => runApp(especialidades());
94
+
95
+class especialidades extends StatelessWidget {
96
+  @override
97
+  Widget build(BuildContext context) {
98
+    return MaterialApp(
99
+      title: 'Flutter Demo',
100
+      theme: ThemeData(
101
+        primarySwatch: Colors.blue,
102
+      ),
103
+      home: SimpleTable(),
104
+    );
105
+  }
106
+}
107
+
108
+
109
+

+ 1
- 1
fast_med_flutter/lib/routes/home.dart View File

@@ -31,7 +31,7 @@ class _HomeState extends State<Home>{
31 31
             spaceBetween(),
32 32
             newButton(context,'/MyApp','MyApp'),
33 33
             spaceBetween(),
34
-            newButton(context,'/album','Ver Oficinas 2: electr'),
34
+            newButton(context,'/especialidades','especialidades'),
35 35
             spaceBetween(),
36 36
             ],
37 37
         ),

+ 14
- 0
fast_med_flutter/pubspec.lock View File

@@ -219,6 +219,20 @@ packages:
219 219
       url: "https://pub.dartlang.org"
220 220
     source: hosted
221 221
     version: "0.6.2"
222
+  json_table:
223
+    dependency: "direct dev"
224
+    description:
225
+      name: json_table
226
+      url: "https://pub.dartlang.org"
227
+    source: hosted
228
+    version: "1.4.0"
229
+  json_utilities:
230
+    dependency: transitive
231
+    description:
232
+      name: json_utilities
233
+      url: "https://pub.dartlang.org"
234
+    source: hosted
235
+    version: "0.1.3"
222 236
   matcher:
223 237
     dependency: transitive
224 238
     description:

+ 1
- 0
fast_med_flutter/pubspec.yaml View File

@@ -43,6 +43,7 @@ assets:
43 43
 dev_dependencies:
44 44
   flutter_test:
45 45
     sdk: flutter
46
+  json_table: 1.4.0
46 47
 
47 48
 # For information on the generic Dart part of this file, see the
48 49
 # following page: https://dart.dev/tools/pub/pubspec