-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcragscreen.dart
63 lines (59 loc) · 1.72 KB
/
cragscreen.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import 'dart:io';
import 'package:ascent/util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'add_crag-ios.dart';
import 'add_crag.dart';
import 'model/crag.dart';
import 'database.dart';
class CragScreen extends StatefulWidget {
@override
_CragScreenState createState() => _CragScreenState();
}
class _CragScreenState extends State<CragScreen> {
@override
Widget build(BuildContext context) {
var body = createScrollView(context, DatabaseHelper.getCrags(), _buildRow);
if (Platform.isIOS) {
return Container(padding: EdgeInsets.only(top: 100.0, bottom: 70), child: body);
}
return Scaffold(
appBar: AppBar(
title: Text('Crags'),
),
body: body,
floatingActionButton: FloatingActionButton(
onPressed: () async {
await Navigator.push(
context,
MaterialPageRoute(builder: (context) => AddCragScreen()),
);
setState(() {});
},
child: Icon(Icons.add),
),
);
}
Widget _buildRow(Crag crag) {
var text = new Text(
crag.name!,
style: Theme.of(context).textTheme.bodyLarge,
);
if (Platform.isIOS) {
return Card(
child: CupertinoListTile(
title: text, onTap: () => showMaterialDialog(context, "Update Crag", CupertinoAddCragScreen(passedCrag: crag), [], 200, 400)),
);
}
return Card(
child: ListTile(
enabled: true,
title: text,
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddCragScreen(
passedCrag: crag,
)))));
}
}