Browse Source

union sprint 1 carlos

Oniel Mendez 3 years ago
parent
commit
3c041c55fa

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

@@ -1,5 +1,6 @@
1 1
 import 'package:fast_med_flutter/routes/home.dart';
2 2
 import 'package:fast_med_flutter/routes/ver_oficinas.dart';
3
+import 'package:fast_med_flutter/routes/especialidades.dart';
3 4
 import 'package:fast_med_flutter/routes/calendario.dart';
4 5
 import 'package:fast_med_flutter/routes/main.dart';
5 6
 import 'package:fast_med_flutter/routes/register.dart';
@@ -15,5 +16,6 @@ void main() => runApp(MaterialApp(
15 16
       '/welcome': (context) => WelcomePage(),
16 17
       '/register': (context) => RegisterPage(),
17 18
       '/MyApp': (context) => MyApp(),
19
+      '/especialidades': (context) => especialidades(),
18 20
     }
19 21
 ));

+ 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

@@ -77,6 +77,18 @@ class _HomeState extends State<Home>{
77 77
               color: Colors.purple,
78 78
 
79 79
             ),
80
+            new FlatButton(
81
+              minWidth: 300.0,
82
+              height: 100.0,
83
+              onPressed: (){
84
+                Navigator.pushNamed(context, '/especialidades');
85
+              },
86
+              child: Text('especialidades',
87
+                style: TextStyle(fontSize: 36),
88
+              ),
89
+              color: Colors.purple,
90
+
91
+            ),
80 92
             ],
81 93
         ),
82 94
 

+ 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

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