-
Notifications
You must be signed in to change notification settings - Fork 0
/
feed_home.dart
56 lines (52 loc) · 1.87 KB
/
feed_home.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
import 'package:flutter/material.dart';
import 'package:handle_it/feed/card/feed_card.dart';
import 'package:handle_it/feed/updaters/sensor_updater.dart';
import 'package:handle_it/feed/~graphql/__generated__/feed_home.query.graphql.dart';
import 'package:handle_it/utils.dart';
import 'package:version/version.dart';
class FeedHome extends StatelessWidget {
const FeedHome({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Query$FeedHome$Widget(
builder: (result, {refetch, fetchMore}) {
final noDataWidget = validateResult(result);
if (noDataWidget != null) return noDataWidget;
final viewer = result.parsedData!.viewer;
final hubs = viewer.user.hubs;
return RefreshIndicator(
onRefresh: () async {
await refetch!();
},
child: ListView(
children: [
SensorUpdater(latestVersion: Version.parse(viewer.latestSensorVersion)),
if (hubs.isNotEmpty)
Padding(
// Prevents covering Arm toggle with fab
padding: const EdgeInsets.only(bottom: 96),
child: Column(
children: hubs
.map((hub) => FeedCard(
hubFrag: hub,
onDelete: () async {
await refetch!();
},
))
.toList(),
),
),
if (hubs.isEmpty)
const Center(
child: Padding(
padding: EdgeInsets.symmetric(vertical: 192),
child: Text(key: ValueKey("text.emptyFeed"), "Add a hub to begin"),
),
)
],
),
);
},
);
}
}