-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linking to a specific boost #2490
Changes from all commits
f41329b
7e07794
c25fd40
8edffab
3014d3f
17e4d52
93425ba
8f9badf
1b8de53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- You can now share boosts via the QR-code | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,10 @@ import 'package:acter/features/news/providers/news_providers.dart'; | |
import 'package:acter/features/news/widgets/news_full_view.dart'; | ||
import 'package:acter/features/news/widgets/news_grid_view.dart'; | ||
import 'package:acter/features/news/widgets/news_skeleton_widget.dart'; | ||
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/l10n.dart'; | ||
import 'package:collection/collection.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:logging/logging.dart'; | ||
|
@@ -20,11 +22,13 @@ enum NewsViewMode { gridView, fullView } | |
|
||
class NewsListPage extends ConsumerStatefulWidget { | ||
final String? spaceId; | ||
final String? initialEventId; | ||
final NewsViewMode newsViewMode; | ||
|
||
const NewsListPage({ | ||
super.key, | ||
this.spaceId, | ||
this.initialEventId, | ||
this.newsViewMode = NewsViewMode.gridView, | ||
}); | ||
|
||
|
@@ -34,12 +38,46 @@ class NewsListPage extends ConsumerStatefulWidget { | |
|
||
class _NewsListPageState extends ConsumerState<NewsListPage> { | ||
final ValueNotifier<bool> useGridMode = ValueNotifier(true); | ||
final ValueNotifier<bool> stillLoadingForSelectedItem = ValueNotifier(false); | ||
final ValueNotifier<int> currentIndex = ValueNotifier(0); | ||
late ProviderSubscription<AsyncValue<List<NewsEntry>>>? listener; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
useGridMode.value = widget.newsViewMode == NewsViewMode.gridView; | ||
final targetEventId = widget.initialEventId; | ||
if (targetEventId != null) { | ||
stillLoadingForSelectedItem.value = true; | ||
listener = ref.listenManual( | ||
newsListProvider(widget.spaceId), | ||
(prev, next) { | ||
final items = next.valueOrNull; | ||
if (items == null) { | ||
return; | ||
} | ||
int? itemIdx; | ||
|
||
items.firstWhereIndexedOrNull((int idx, NewsEntry e) { | ||
if (e.eventId().toString() == targetEventId) { | ||
itemIdx = idx; | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}); | ||
if (itemIdx == null) { | ||
// not found, still loading | ||
return; | ||
Comment on lines
+69
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happen if boost is deleted by user/You try to scan QR of different space which he/she haven't joined yet? This will remain in still loading forever? This can happen specially in ExternalLink sharing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this code - as well as any other where we have that case - this is endlessly loading, yes. The plan is to have that case figured and caught in the url-parser and show something else in these cases: a message with the room they need to join first. If it was deleted I am not sure what we want to do instead, but I'd just put that onto the lower burner for now, not a major use case. |
||
} | ||
stillLoadingForSelectedItem.value = false; | ||
currentIndex.value = itemIdx!; | ||
listener?.close(); | ||
listener = null; | ||
}, | ||
fireImmediately: true, | ||
); | ||
} | ||
} | ||
|
||
@override | ||
|
@@ -50,7 +88,11 @@ class _NewsListPageState extends ConsumerState<NewsListPage> { | |
return Scaffold( | ||
extendBodyBehindAppBar: !value, | ||
appBar: _buildAppBar(value), | ||
body: _buildBody(value), | ||
body: ValueListenableBuilder( | ||
valueListenable: stillLoadingForSelectedItem, | ||
builder: (context, loading, child) => | ||
loading ? const NewsSkeletonWidget() : _buildBody(value), | ||
), | ||
); | ||
}, | ||
); | ||
|
@@ -119,6 +161,8 @@ class _NewsListPageState extends ConsumerState<NewsListPage> { | |
}, | ||
error: (e, s) => newsErrorUI(context, e, s), | ||
loading: () => const NewsSkeletonWidget(), | ||
skipLoadingOnRefresh: true, | ||
skipLoadingOnReload: true, | ||
); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only via QR Code?
External sharing doesn't yet supported? I have seen external sharing options in video and haven't see any QR Specific restriction in this PR code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changelog is meant to be user-facing thus I am focusing on the thing that already works nicely. The external sharing - as you point out correctly - still has some bugs so I am not advertising it here yet, despite it already being technically possible...