Browse Source

union sprint 1 carlos

Oniel Mendez 4 years ago
parent
commit
d51b36bd02

+ 4
- 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,8 @@ 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(),
22 24
     }
23 25
 ));

+ 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
+

+ 12
- 0
fast_med_flutter/lib/routes/home.dart View File

@@ -87,6 +87,18 @@ class _HomeState extends State<Home>{
87 87
               color: Colors.purple,
88 88
 
89 89
             ),
90
+            new FlatButton(
91
+              minWidth: 300.0,
92
+              height: 100.0,
93
+              onPressed: (){
94
+                Navigator.pushNamed(context, '/especialidades');
95
+              },
96
+              child: Text('especialidades',
97
+                style: TextStyle(fontSize: 36),
98
+              ),
99
+              color: Colors.purple,
100
+
101
+            ),
90 102
             //aqui termina lo que merge
91 103
             ],
92 104
         ),

+ 14
- 0
fast_med_flutter/pubspec.lock View File

@@ -247,6 +247,20 @@ packages:
247 247
       url: "https://pub.dartlang.org"
248 248
     source: hosted
249 249
     version: "0.6.2"
250
+  json_table:
251
+    dependency: "direct dev"
252
+    description:
253
+      name: json_table
254
+      url: "https://pub.dartlang.org"
255
+    source: hosted
256
+    version: "1.4.0"
257
+  json_utilities:
258
+    dependency: transitive
259
+    description:
260
+      name: json_utilities
261
+      url: "https://pub.dartlang.org"
262
+    source: hosted
263
+    version: "0.1.3"
250 264
   matcher:
251 265
     dependency: transitive
252 266
     description:

+ 1
- 0
fast_med_flutter/pubspec.yaml View File

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