🧱 New categories, tags subscription type
This commit is contained in:
@@ -4,14 +4,17 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:island/models/post.dart';
|
||||
import 'package:island/models/post_category.dart';
|
||||
import 'package:island/pods/network.dart';
|
||||
import 'package:island/widgets/content/cloud_files.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
||||
final subscriptionsProvider = FutureProvider<List<SnPublisherSubscription>>((
|
||||
ref,
|
||||
) async {
|
||||
part 'post_subscription_filter.g.dart';
|
||||
|
||||
@riverpod
|
||||
Future<List<SnPublisherSubscription>> publishersSubscriptions(Ref ref) async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
|
||||
final response = await client.get('/sphere/publishers/subscriptions');
|
||||
@@ -20,7 +23,19 @@ final subscriptionsProvider = FutureProvider<List<SnPublisherSubscription>>((
|
||||
.map((json) => SnPublisherSubscription.fromJson(json))
|
||||
.cast<SnPublisherSubscription>()
|
||||
.toList();
|
||||
});
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<List<SnCategorySubscription>> categoriesSubscriptions(Ref ref) async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
|
||||
final response = await client.get('/sphere/categories/subscriptions');
|
||||
|
||||
return response.data
|
||||
.map((json) => SnCategorySubscription.fromJson(json))
|
||||
.cast<SnCategorySubscription>()
|
||||
.toList();
|
||||
}
|
||||
|
||||
class PostSubscriptionFilterWidget extends HookConsumerWidget {
|
||||
final List<String> initialSelectedPublisherNames;
|
||||
@@ -40,7 +55,7 @@ class PostSubscriptionFilterWidget extends HookConsumerWidget {
|
||||
initialSelectedPublisherNames,
|
||||
);
|
||||
|
||||
final subscriptionsAsync = ref.watch(subscriptionsProvider);
|
||||
final subscriptionsAsync = ref.watch(publishersSubscriptionsProvider);
|
||||
|
||||
void updateSelection() {
|
||||
onSelectedPublishersChanged(selectedPublisherNames.value);
|
||||
|
||||
94
lib/widgets/posts/post_subscription_filter.g.dart
Normal file
94
lib/widgets/posts/post_subscription_filter.g.dart
Normal file
@@ -0,0 +1,94 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'post_subscription_filter.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(publishersSubscriptions)
|
||||
const publishersSubscriptionsProvider = PublishersSubscriptionsProvider._();
|
||||
|
||||
final class PublishersSubscriptionsProvider
|
||||
extends
|
||||
$FunctionalProvider<
|
||||
AsyncValue<List<SnPublisherSubscription>>,
|
||||
List<SnPublisherSubscription>,
|
||||
FutureOr<List<SnPublisherSubscription>>
|
||||
>
|
||||
with
|
||||
$FutureModifier<List<SnPublisherSubscription>>,
|
||||
$FutureProvider<List<SnPublisherSubscription>> {
|
||||
const PublishersSubscriptionsProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'publishersSubscriptionsProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$publishersSubscriptionsHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$FutureProviderElement<List<SnPublisherSubscription>> $createElement(
|
||||
$ProviderPointer pointer,
|
||||
) => $FutureProviderElement(pointer);
|
||||
|
||||
@override
|
||||
FutureOr<List<SnPublisherSubscription>> create(Ref ref) {
|
||||
return publishersSubscriptions(ref);
|
||||
}
|
||||
}
|
||||
|
||||
String _$publishersSubscriptionsHash() =>
|
||||
r'208463c1f879a3ddab4092112e312a0cd27ebc2f';
|
||||
|
||||
@ProviderFor(categoriesSubscriptions)
|
||||
const categoriesSubscriptionsProvider = CategoriesSubscriptionsProvider._();
|
||||
|
||||
final class CategoriesSubscriptionsProvider
|
||||
extends
|
||||
$FunctionalProvider<
|
||||
AsyncValue<List<SnCategorySubscription>>,
|
||||
List<SnCategorySubscription>,
|
||||
FutureOr<List<SnCategorySubscription>>
|
||||
>
|
||||
with
|
||||
$FutureModifier<List<SnCategorySubscription>>,
|
||||
$FutureProvider<List<SnCategorySubscription>> {
|
||||
const CategoriesSubscriptionsProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'categoriesSubscriptionsProvider',
|
||||
isAutoDispose: true,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$categoriesSubscriptionsHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$FutureProviderElement<List<SnCategorySubscription>> $createElement(
|
||||
$ProviderPointer pointer,
|
||||
) => $FutureProviderElement(pointer);
|
||||
|
||||
@override
|
||||
FutureOr<List<SnCategorySubscription>> create(Ref ref) {
|
||||
return categoriesSubscriptions(ref);
|
||||
}
|
||||
}
|
||||
|
||||
String _$categoriesSubscriptionsHash() =>
|
||||
r'14a8f04d258d1a10aae20ca959495926840c9386';
|
||||
Reference in New Issue
Block a user