Skip to content

Commit 1f0494c

Browse files
committed
Add linking to users and groups tab view, fix various linking bugs
1 parent 8d89823 commit 1f0494c

File tree

16 files changed

+136
-108
lines changed

16 files changed

+136
-108
lines changed

api/lib/models/event/user.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class EventUserDatabaseConnector extends DatabaseModelConnector<User, Event> {
2323
'$tableName JOIN events ON eventId = events.id',
2424
limit: limit,
2525
offset: offset,
26-
where: 'groupId = ?',
26+
where: 'userId = ?',
2727
whereArgs: [itemId],
2828
);
2929
return result?.map((e) => Event.fromDatabase(e)).toList() ?? [];
@@ -36,7 +36,7 @@ class EventUserDatabaseConnector extends DatabaseModelConnector<User, Event> {
3636
'$tableName JOIN users ON userId = users.id',
3737
limit: limit,
3838
offset: offset,
39-
where: 'userId = ?',
39+
where: 'eventId = ?',
4040
whereArgs: [connectId],
4141
);
4242
return result?.map((e) => User.fromDatabase(e)).toList() ?? [];

api/pubspec.lock

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ packages:
121121
url: "https://pub.dev"
122122
source: hosted
123123
version: "2.0.3"
124+
cli_config:
125+
dependency: transitive
126+
description:
127+
name: cli_config
128+
sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec
129+
url: "https://pub.dev"
130+
source: hosted
131+
version: "0.2.0"
124132
code_builder:
125133
dependency: transitive
126134
description:
@@ -149,10 +157,10 @@ packages:
149157
dependency: transitive
150158
description:
151159
name: coverage
152-
sha256: e3493833ea012784c740e341952298f1cc77f1f01b1bbc3eb4eecf6984fb7f43
160+
sha256: "9086475ef2da7102a0c0a4e37e1e30707e7fb7b6d28c209f559a9c5f8ce42016"
153161
url: "https://pub.dev"
154162
source: hosted
155-
version: "1.11.1"
163+
version: "1.12.0"
156164
crypto:
157165
dependency: transitive
158166
description:

app/android/Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ GEM
1111
artifactory (3.0.17)
1212
atomos (0.1.3)
1313
aws-eventstream (1.3.2)
14-
aws-partitions (1.1082.0)
14+
aws-partitions (1.1086.0)
1515
aws-sdk-core (3.222.1)
1616
aws-eventstream (~> 1, >= 1.3.0)
1717
aws-partitions (~> 1, >= 1.992.0)
@@ -71,7 +71,7 @@ GEM
7171
faraday_middleware (1.2.1)
7272
faraday (~> 1.0)
7373
fastimage (2.4.0)
74-
fastlane (2.227.0)
74+
fastlane (2.227.1)
7575
CFPropertyList (>= 2.3, < 4.0.0)
7676
addressable (>= 2.8, < 3.0.0)
7777
artifactory (~> 3.0)
@@ -111,7 +111,7 @@ GEM
111111
tty-spinner (>= 0.8.0, < 1.0.0)
112112
word_wrap (~> 1.0.0)
113113
xcodeproj (>= 1.13.0, < 2.0.0)
114-
xcpretty (~> 0.4.0)
114+
xcpretty (~> 0.4.1)
115115
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
116116
fastlane-sirp (1.0.0)
117117
sysrandom (~> 1.0)
@@ -231,4 +231,4 @@ DEPENDENCIES
231231
screengrab
232232

233233
BUNDLED WITH
234-
2.6.7
234+
2.6.8

app/lib/blocs/sourced_paging.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ class SourcedPagingBloc<T>
4040
}
4141

4242
SourcedPagingBloc.item(
43-
{required this.cubit, this.sources, required fetch, this.pageSize = 50})
43+
{required this.cubit,
44+
this.sources,
45+
required ItemFetcher<T> fetch,
46+
this.pageSize = 50})
4447
: useDates = false,
4548
_fetch = _buildDatedFetch(fetch),
4649
super(const SourcedPagingInitial()) {
@@ -50,7 +53,7 @@ class SourcedPagingBloc<T>
5053
SourcedPagingBloc.source({
5154
required this.cubit,
5255
required String source,
53-
required SourceFetcher fetch,
56+
required SourceFetcher<T> fetch,
5457
this.pageSize = 50,
5558
}) : sources = [source],
5659
useDates = false,
@@ -164,12 +167,12 @@ class SourcedPagingBloc<T>
164167
void removeSourced(T item) => add(SourcedPagingRemoved(item));
165168
}
166169

167-
_buildDatedFetch<T>(ItemFetcher fetch) => (String source, SourceService service,
168-
int offset, int limit, int date) async {
170+
_buildDatedFetch<T>(ItemFetcher<T> fetch) => (String source,
171+
SourceService service, int offset, int limit, int date) async {
169172
final items = await fetch(source, service, offset, limit);
170173
return items;
171174
};
172-
_buildDatedFetchSource<T>(SourceFetcher fetch) => (String source,
175+
_buildDatedFetchSource<T>(SourceFetcher<T> fetch) => (String source,
173176
SourceService service, int offset, int limit, int date) async {
174177
final items = await fetch(service, offset, limit);
175178
return items;

app/lib/pages/groups/page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class _GroupsBodyViewState extends State<GroupsBodyView> {
9292
@override
9393
void initState() {
9494
_flowCubit = context.read<FlowCubit>();
95-
_bloc = SourcedPagingBloc.item(
95+
_bloc = SourcedPagingBloc<Group>.item(
9696
cubit: _flowCubit,
9797
fetch: (source, service, offset, limit) async =>
9898
service.group?.getGroups(offset: offset, limit: limit));

app/lib/pages/groups/view.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flow/blocs/sourced_paging.dart';
2+
import 'package:flow/pages/groups/select.dart';
23
import 'package:flow/widgets/paging/list.dart';
34
import 'package:flow_api/services/source.dart';
45
import 'package:flutter/material.dart';
@@ -66,7 +67,10 @@ class _GroupsViewState<T extends DescriptiveModel>
6667
key: ValueKey(item.id),
6768
background: Container(color: Colors.red),
6869
onDismissed: (direction) {
69-
_groupService?.deleteGroup(item.id!);
70+
widget.connector.disconnect(
71+
widget.model.id!,
72+
item.id!,
73+
);
7074
_bloc.removeSourced(item);
7175
},
7276
child: ListTile(
@@ -94,12 +98,12 @@ class _GroupsViewState<T extends DescriptiveModel>
9498
child: Padding(
9599
padding: const EdgeInsets.all(16.0),
96100
child: FloatingActionButton.extended(
97-
label: Text(AppLocalizations.of(context).create),
98-
icon: const PhosphorIcon(PhosphorIconsLight.plus),
101+
label: Text(AppLocalizations.of(context).link),
102+
icon: const PhosphorIcon(PhosphorIconsLight.link),
99103
onPressed: () async {
100104
final group = await showDialog<SourcedModel<Group>>(
101105
context: context,
102-
builder: (context) => GroupDialog(
106+
builder: (context) => GroupSelectDialog(
103107
source: widget.source,
104108
),
105109
);

app/lib/pages/notes/view.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ class _NotesViewState<T extends DescriptiveModel> extends State<NotesView<T>> {
6464
key: ValueKey(item.id),
6565
background: Container(color: Colors.red),
6666
onDismissed: (direction) {
67-
_noteService?.deleteNote(item.id!);
67+
widget.connector.disconnect(
68+
widget.model.id!,
69+
item.id!,
70+
);
6871
_bloc.removeSourced(item);
6972
},
7073
child: ListTile(

app/lib/pages/resources/view.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ class _ResourcesViewState<T extends DescriptiveModel>
6464
key: ValueKey(item.id),
6565
background: Container(color: Colors.red),
6666
onDismissed: (direction) {
67-
_resourceService?.deleteResource(item.id!);
67+
widget.connector.disconnect(
68+
widget.model.id!,
69+
item.id!,
70+
);
6871
_bloc.removeSourced(item);
6972
},
7073
child: ListTile(

app/lib/pages/users/page.dart

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class _UsersBodyViewState extends State<UsersBodyView> {
109109
@override
110110
void initState() {
111111
_flowCubit = context.read<FlowCubit>();
112-
_bloc = SourcedPagingBloc.item(
112+
_bloc = SourcedPagingBloc<User>.item(
113113
cubit: _flowCubit,
114114
fetch: (source, service, offset, limit) async =>
115115
_filter.source != null && _filter.source != source
@@ -141,49 +141,51 @@ class _UsersBodyViewState extends State<UsersBodyView> {
141141
@override
142142
Widget build(BuildContext context) {
143143
return Scaffold(
144-
body: Column(
145-
children: [
146-
UserFilterView(
147-
initialFilter: _filter,
148-
onChanged: (filter) {
149-
setState(() {
150-
_filter = filter;
151-
});
152-
_bloc.refresh();
153-
},
154-
),
155-
const SizedBox(height: 8),
156-
Expanded(
157-
child: PagedListView.item(
158-
bloc: _bloc,
159-
itemBuilder: (ctx, item, index) => Align(
160-
alignment: Alignment.topCenter,
161-
child: Container(
162-
constraints: const BoxConstraints(maxWidth: 800),
163-
child: Dismissible(
164-
key: ValueKey('${item.model.id}@${item.source}'),
165-
onDismissed: (direction) async {
166-
await _flowCubit
167-
.getService(item.source)
168-
.user
169-
?.deleteUser(item.model.id!);
170-
_bloc.remove(item);
171-
},
172-
background: Container(
173-
color: Colors.red,
174-
),
175-
child: UserTile(
176-
flowCubit: _flowCubit,
177-
bloc: _bloc,
178-
source: item.source,
179-
user: item.model,
144+
body: Center(
145+
child: Column(
146+
crossAxisAlignment: CrossAxisAlignment.center,
147+
children: [
148+
UserFilterView(
149+
initialFilter: _filter,
150+
onChanged: (filter) {
151+
setState(() {
152+
_filter = filter;
153+
});
154+
_bloc.refresh();
155+
},
156+
),
157+
const SizedBox(height: 8),
158+
Expanded(
159+
child: PagedListView.item(
160+
bloc: _bloc,
161+
itemBuilder: (ctx, item, index) => Center(
162+
child: Container(
163+
constraints: const BoxConstraints(maxWidth: 800),
164+
child: Dismissible(
165+
key: ValueKey('${item.model.id}@${item.source}'),
166+
onDismissed: (direction) async {
167+
await _flowCubit
168+
.getService(item.source)
169+
.user
170+
?.deleteUser(item.model.id!);
171+
_bloc.remove(item);
172+
},
173+
background: Container(
174+
color: Colors.red,
175+
),
176+
child: UserTile(
177+
flowCubit: _flowCubit,
178+
bloc: _bloc,
179+
source: item.source,
180+
user: item.model,
181+
),
180182
),
181183
),
182184
),
183185
),
184186
),
185-
),
186-
],
187+
],
188+
),
187189
),
188190
floatingActionButton: FloatingActionButton.extended(
189191
onPressed: () => showDialog(

app/lib/pages/users/user.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flow/widgets/markdown_field.dart';
2+
import 'package:flow_api/models/model.dart';
23
import 'package:flutter/material.dart';
34
import 'package:flutter_bloc/flutter_bloc.dart';
45
import 'package:flow/src/generated/i18n/app_localizations.dart';
@@ -83,7 +84,8 @@ class UserDialog extends StatelessWidget {
8384
await currentService?.updateUser(currentUser);
8485
}
8586
if (context.mounted) {
86-
Navigator.of(context).pop(currentUser);
87+
Navigator.of(context)
88+
.pop(SourcedModel(currentSource, currentUser));
8789
}
8890
},
8991
child: Text(AppLocalizations.of(context).save),

0 commit comments

Comments
 (0)