Added tag bookmarks screen
This commit is contained in:
@@ -4,9 +4,9 @@
|
|||||||
/// To regenerate, run: `dart run slang`
|
/// To regenerate, run: `dart run slang`
|
||||||
///
|
///
|
||||||
/// Locales: 2
|
/// Locales: 2
|
||||||
/// Strings: 224 (112 per locale)
|
/// Strings: 226 (113 per locale)
|
||||||
///
|
///
|
||||||
/// Built on 2024-02-24 at 15:14 UTC
|
/// Built on 2024-02-24 at 17:36 UTC
|
||||||
|
|
||||||
// coverage:ignore-file
|
// coverage:ignore-file
|
||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
@@ -229,6 +229,7 @@ class _StringsTagsEn {
|
|||||||
String get tags => 'Tags';
|
String get tags => 'Tags';
|
||||||
String created({required Object created}) => 'Created: ${created}';
|
String created({required Object created}) => 'Created: ${created}';
|
||||||
late final _StringsTagsCreateTagEn createTag = _StringsTagsCreateTagEn._(_root);
|
late final _StringsTagsCreateTagEn createTag = _StringsTagsCreateTagEn._(_root);
|
||||||
|
late final _StringsTagsTagBookmarksEn tagBookmarks = _StringsTagsTagBookmarksEn._(_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path: settings
|
// Path: settings
|
||||||
@@ -356,6 +357,16 @@ class _StringsTagsCreateTagEn {
|
|||||||
String get errorCreatingTag => 'An error occured when creating the tag.';
|
String get errorCreatingTag => 'An error occured when creating the tag.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Path: tags.tagBookmarks
|
||||||
|
class _StringsTagsTagBookmarksEn {
|
||||||
|
_StringsTagsTagBookmarksEn._(this._root);
|
||||||
|
|
||||||
|
final Translations _root; // ignore: unused_field
|
||||||
|
|
||||||
|
// Translations
|
||||||
|
String get noBookmarksWithThisTag => 'There are no bookmarks with this tag';
|
||||||
|
}
|
||||||
|
|
||||||
// Path: settings.customization
|
// Path: settings.customization
|
||||||
class _StringsSettingsCustomizationEn {
|
class _StringsSettingsCustomizationEn {
|
||||||
_StringsSettingsCustomizationEn._(this._root);
|
_StringsSettingsCustomizationEn._(this._root);
|
||||||
@@ -507,6 +518,7 @@ class _StringsTagsEs implements _StringsTagsEn {
|
|||||||
@override String get tags => 'Etiquetas';
|
@override String get tags => 'Etiquetas';
|
||||||
@override String created({required Object created}) => 'Creado: ${created}';
|
@override String created({required Object created}) => 'Creado: ${created}';
|
||||||
@override late final _StringsTagsCreateTagEs createTag = _StringsTagsCreateTagEs._(_root);
|
@override late final _StringsTagsCreateTagEs createTag = _StringsTagsCreateTagEs._(_root);
|
||||||
|
@override late final _StringsTagsTagBookmarksEs tagBookmarks = _StringsTagsTagBookmarksEs._(_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path: settings
|
// Path: settings
|
||||||
@@ -634,6 +646,16 @@ class _StringsTagsCreateTagEs implements _StringsTagsCreateTagEn {
|
|||||||
@override String get errorCreatingTag => 'Ocurrió un error al crear la etiqueta.';
|
@override String get errorCreatingTag => 'Ocurrió un error al crear la etiqueta.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Path: tags.tagBookmarks
|
||||||
|
class _StringsTagsTagBookmarksEs implements _StringsTagsTagBookmarksEn {
|
||||||
|
_StringsTagsTagBookmarksEs._(this._root);
|
||||||
|
|
||||||
|
@override final _StringsEs _root; // ignore: unused_field
|
||||||
|
|
||||||
|
// Translations
|
||||||
|
@override String get noBookmarksWithThisTag => 'No hay marcadores con esta etiqueta';
|
||||||
|
}
|
||||||
|
|
||||||
// Path: settings.customization
|
// Path: settings.customization
|
||||||
class _StringsSettingsCustomizationEs implements _StringsSettingsCustomizationEn {
|
class _StringsSettingsCustomizationEs implements _StringsSettingsCustomizationEn {
|
||||||
_StringsSettingsCustomizationEs._(this._root);
|
_StringsSettingsCustomizationEs._(this._root);
|
||||||
@@ -755,6 +777,7 @@ extension on Translations {
|
|||||||
case 'tags.createTag.name': return 'Name';
|
case 'tags.createTag.name': return 'Name';
|
||||||
case 'tags.createTag.creatingTag': return 'Creating tag...';
|
case 'tags.createTag.creatingTag': return 'Creating tag...';
|
||||||
case 'tags.createTag.errorCreatingTag': return 'An error occured when creating the tag.';
|
case 'tags.createTag.errorCreatingTag': return 'An error occured when creating the tag.';
|
||||||
|
case 'tags.tagBookmarks.noBookmarksWithThisTag': return 'There are no bookmarks with this tag';
|
||||||
case 'settings.settings': return 'Settings';
|
case 'settings.settings': return 'Settings';
|
||||||
case 'settings.appSettings': return 'App settings';
|
case 'settings.appSettings': return 'App settings';
|
||||||
case 'settings.aboutApp': return 'About the app';
|
case 'settings.aboutApp': return 'About the app';
|
||||||
@@ -875,6 +898,7 @@ extension on _StringsEs {
|
|||||||
case 'tags.createTag.name': return 'Nombre';
|
case 'tags.createTag.name': return 'Nombre';
|
||||||
case 'tags.createTag.creatingTag': return 'Creando etiqueta...';
|
case 'tags.createTag.creatingTag': return 'Creando etiqueta...';
|
||||||
case 'tags.createTag.errorCreatingTag': return 'Ocurrió un error al crear la etiqueta.';
|
case 'tags.createTag.errorCreatingTag': return 'Ocurrió un error al crear la etiqueta.';
|
||||||
|
case 'tags.tagBookmarks.noBookmarksWithThisTag': return 'No hay marcadores con esta etiqueta';
|
||||||
case 'settings.settings': return 'Ajustes';
|
case 'settings.settings': return 'Ajustes';
|
||||||
case 'settings.appSettings': return 'Ajustes de la aplicación';
|
case 'settings.appSettings': return 'Ajustes de la aplicación';
|
||||||
case 'settings.aboutApp': return 'Sobre la aplicación';
|
case 'settings.aboutApp': return 'Sobre la aplicación';
|
||||||
|
|||||||
@@ -82,6 +82,9 @@
|
|||||||
"name": "Name",
|
"name": "Name",
|
||||||
"creatingTag": "Creating tag...",
|
"creatingTag": "Creating tag...",
|
||||||
"errorCreatingTag": "An error occured when creating the tag."
|
"errorCreatingTag": "An error occured when creating the tag."
|
||||||
|
},
|
||||||
|
"tagBookmarks": {
|
||||||
|
"noBookmarksWithThisTag": "There are no bookmarks with this tag"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
|
|||||||
@@ -82,6 +82,9 @@
|
|||||||
"name": "Nombre",
|
"name": "Nombre",
|
||||||
"creatingTag": "Creando etiqueta...",
|
"creatingTag": "Creando etiqueta...",
|
||||||
"errorCreatingTag": "Ocurrió un error al crear la etiqueta."
|
"errorCreatingTag": "Ocurrió un error al crear la etiqueta."
|
||||||
|
},
|
||||||
|
"tagBookmarks": {
|
||||||
|
"noBookmarksWithThisTag": "No hay marcadores con esta etiqueta"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ final selectedThemeProvider = AutoDisposeProvider<ThemeMode>.internal(
|
|||||||
);
|
);
|
||||||
|
|
||||||
typedef SelectedThemeRef = AutoDisposeProviderRef<ThemeMode>;
|
typedef SelectedThemeRef = AutoDisposeProviderRef<ThemeMode>;
|
||||||
String _$appStatusHash() => r'7f263e1933715c0ec6305e453af99b9a264156b6';
|
String _$appStatusHash() => r'3b87acee218adcc5707acfb30fd6e5c650b410ce';
|
||||||
|
|
||||||
/// See also [AppStatus].
|
/// See also [AppStatus].
|
||||||
@ProviderFor(AppStatus)
|
@ProviderFor(AppStatus)
|
||||||
|
|||||||
3
lib/router/names.dart
Normal file
3
lib/router/names.dart
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class RoutesNames {
|
||||||
|
static const tagBookmarks = "tagBookmarks";
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ class RoutesPaths {
|
|||||||
static const bookmarksSearch = "/bookmarks/search";
|
static const bookmarksSearch = "/bookmarks/search";
|
||||||
static const webview = "/webview";
|
static const webview = "/webview";
|
||||||
static const tags = "/tags";
|
static const tags = "/tags";
|
||||||
|
static const tagBookmarks = "/tags/:id";
|
||||||
static const settings = "/settings";
|
static const settings = "/settings";
|
||||||
static const customization = "/settings/customization";
|
static const customization = "/settings/customization";
|
||||||
static const generalSettings = "/settings/general";
|
static const generalSettings = "/settings/general";
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:linkdy/models/data/tags.dart';
|
||||||
|
import 'package:linkdy/router/names.dart';
|
||||||
|
|
||||||
import 'package:linkdy/screens/bookmarks/ui/bookmarks.dart';
|
import 'package:linkdy/screens/bookmarks/ui/bookmarks.dart';
|
||||||
import 'package:linkdy/screens/bookmarks/ui/search_bookmarks.dart';
|
import 'package:linkdy/screens/bookmarks/ui/search_bookmarks.dart';
|
||||||
@@ -7,6 +9,7 @@ import 'package:linkdy/screens/onboarding/ui/onboarding.dart';
|
|||||||
import 'package:linkdy/screens/settings/ui/customization/customization.dart';
|
import 'package:linkdy/screens/settings/ui/customization/customization.dart';
|
||||||
import 'package:linkdy/screens/settings/ui/general_settings/general_settings.dart';
|
import 'package:linkdy/screens/settings/ui/general_settings/general_settings.dart';
|
||||||
import 'package:linkdy/screens/settings/ui/settings.dart';
|
import 'package:linkdy/screens/settings/ui/settings.dart';
|
||||||
|
import 'package:linkdy/screens/tag_bookmarks/ui/tag_bookmarks.dart';
|
||||||
import 'package:linkdy/screens/tags/ui/tags.dart';
|
import 'package:linkdy/screens/tags/ui/tags.dart';
|
||||||
import 'package:linkdy/screens/webview/ui/webview.dart';
|
import 'package:linkdy/screens/webview/ui/webview.dart';
|
||||||
import 'package:linkdy/widgets/layout.dart';
|
import 'package:linkdy/widgets/layout.dart';
|
||||||
@@ -49,6 +52,11 @@ final List<RouteBase> appRoutes = [
|
|||||||
path: RoutesPaths.bookmarksSearch,
|
path: RoutesPaths.bookmarksSearch,
|
||||||
builder: (context, state) => const SearchBookmarksScreen(),
|
builder: (context, state) => const SearchBookmarksScreen(),
|
||||||
),
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: RoutesPaths.tagBookmarks,
|
||||||
|
name: RoutesNames.tagBookmarks,
|
||||||
|
builder: (context, state) => TagBookmarksScreen(tag: state.extra as Tag),
|
||||||
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: RoutesPaths.customization,
|
path: RoutesPaths.customization,
|
||||||
builder: (context, state) => const Customization(),
|
builder: (context, state) => const Customization(),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:linkdy/models/data/bookmarks.dart';
|
import 'package:linkdy/models/data/bookmarks.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
import 'package:linkdy/screens/bookmarks/model/links.model.dart';
|
import 'package:linkdy/screens/bookmarks/model/bookmarks.model.dart';
|
||||||
|
|
||||||
import 'package:linkdy/models/api_response.dart';
|
import 'package:linkdy/models/api_response.dart';
|
||||||
import 'package:linkdy/providers/api_client_provider.dart';
|
import 'package:linkdy/providers/api_client_provider.dart';
|
||||||
|
|||||||
9
lib/screens/tag_bookmarks/model/tag_bookmarks.model.dart
Normal file
9
lib/screens/tag_bookmarks/model/tag_bookmarks.model.dart
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class TagBookmarksModel {
|
||||||
|
int currentPage;
|
||||||
|
int limit;
|
||||||
|
|
||||||
|
TagBookmarksModel({
|
||||||
|
this.currentPage = 0,
|
||||||
|
this.limit = 100,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
|
import 'package:linkdy/screens/tag_bookmarks/model/tag_bookmarks.model.dart';
|
||||||
|
|
||||||
|
import 'package:linkdy/models/api_response.dart';
|
||||||
|
import 'package:linkdy/models/data/bookmarks.dart';
|
||||||
|
import 'package:linkdy/providers/api_client_provider.dart';
|
||||||
|
|
||||||
|
part 'tag_bookmarks.provider.g.dart';
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
FutureOr<ApiResponse<BookmarksResponse>> tagBookmarksRequest(TagBookmarksRequestRef ref, String tagName) async {
|
||||||
|
final result = await ref.watch(apiClientProvider)!.fetchBookmarks(q: tagName);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@riverpod
|
||||||
|
class TagBookmarks extends _$TagBookmarks {
|
||||||
|
@override
|
||||||
|
TagBookmarksModel build() {
|
||||||
|
return TagBookmarksModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCurrentPage(int page) {
|
||||||
|
state.currentPage = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLimit(int limit) {
|
||||||
|
state.limit = limit;
|
||||||
|
}
|
||||||
|
}
|
||||||
182
lib/screens/tag_bookmarks/provider/tag_bookmarks.provider.g.dart
Normal file
182
lib/screens/tag_bookmarks/provider/tag_bookmarks.provider.g.dart
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'tag_bookmarks.provider.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
String _$tagBookmarksRequestHash() =>
|
||||||
|
r'0625c18022480eb1356396d9e46f677f21106797';
|
||||||
|
|
||||||
|
/// Copied from Dart SDK
|
||||||
|
class _SystemHash {
|
||||||
|
_SystemHash._();
|
||||||
|
|
||||||
|
static int combine(int hash, int value) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + value);
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
|
||||||
|
return hash ^ (hash >> 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int finish(int hash) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
|
||||||
|
// ignore: parameter_assignments
|
||||||
|
hash = hash ^ (hash >> 11);
|
||||||
|
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [tagBookmarksRequest].
|
||||||
|
@ProviderFor(tagBookmarksRequest)
|
||||||
|
const tagBookmarksRequestProvider = TagBookmarksRequestFamily();
|
||||||
|
|
||||||
|
/// See also [tagBookmarksRequest].
|
||||||
|
class TagBookmarksRequestFamily
|
||||||
|
extends Family<AsyncValue<ApiResponse<BookmarksResponse>>> {
|
||||||
|
/// See also [tagBookmarksRequest].
|
||||||
|
const TagBookmarksRequestFamily();
|
||||||
|
|
||||||
|
/// See also [tagBookmarksRequest].
|
||||||
|
TagBookmarksRequestProvider call(
|
||||||
|
String tagName,
|
||||||
|
) {
|
||||||
|
return TagBookmarksRequestProvider(
|
||||||
|
tagName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
TagBookmarksRequestProvider getProviderOverride(
|
||||||
|
covariant TagBookmarksRequestProvider provider,
|
||||||
|
) {
|
||||||
|
return call(
|
||||||
|
provider.tagName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||||
|
|
||||||
|
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||||
|
_allTransitiveDependencies;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get name => r'tagBookmarksRequestProvider';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See also [tagBookmarksRequest].
|
||||||
|
class TagBookmarksRequestProvider
|
||||||
|
extends AutoDisposeFutureProvider<ApiResponse<BookmarksResponse>> {
|
||||||
|
/// See also [tagBookmarksRequest].
|
||||||
|
TagBookmarksRequestProvider(
|
||||||
|
String tagName,
|
||||||
|
) : this._internal(
|
||||||
|
(ref) => tagBookmarksRequest(
|
||||||
|
ref as TagBookmarksRequestRef,
|
||||||
|
tagName,
|
||||||
|
),
|
||||||
|
from: tagBookmarksRequestProvider,
|
||||||
|
name: r'tagBookmarksRequestProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$tagBookmarksRequestHash,
|
||||||
|
dependencies: TagBookmarksRequestFamily._dependencies,
|
||||||
|
allTransitiveDependencies:
|
||||||
|
TagBookmarksRequestFamily._allTransitiveDependencies,
|
||||||
|
tagName: tagName,
|
||||||
|
);
|
||||||
|
|
||||||
|
TagBookmarksRequestProvider._internal(
|
||||||
|
super._createNotifier, {
|
||||||
|
required super.name,
|
||||||
|
required super.dependencies,
|
||||||
|
required super.allTransitiveDependencies,
|
||||||
|
required super.debugGetCreateSourceHash,
|
||||||
|
required super.from,
|
||||||
|
required this.tagName,
|
||||||
|
}) : super.internal();
|
||||||
|
|
||||||
|
final String tagName;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Override overrideWith(
|
||||||
|
FutureOr<ApiResponse<BookmarksResponse>> Function(
|
||||||
|
TagBookmarksRequestRef provider)
|
||||||
|
create,
|
||||||
|
) {
|
||||||
|
return ProviderOverride(
|
||||||
|
origin: this,
|
||||||
|
override: TagBookmarksRequestProvider._internal(
|
||||||
|
(ref) => create(ref as TagBookmarksRequestRef),
|
||||||
|
from: from,
|
||||||
|
name: null,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
debugGetCreateSourceHash: null,
|
||||||
|
tagName: tagName,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AutoDisposeFutureProviderElement<ApiResponse<BookmarksResponse>>
|
||||||
|
createElement() {
|
||||||
|
return _TagBookmarksRequestProviderElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return other is TagBookmarksRequestProvider && other.tagName == tagName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode {
|
||||||
|
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||||
|
hash = _SystemHash.combine(hash, tagName.hashCode);
|
||||||
|
|
||||||
|
return _SystemHash.finish(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mixin TagBookmarksRequestRef
|
||||||
|
on AutoDisposeFutureProviderRef<ApiResponse<BookmarksResponse>> {
|
||||||
|
/// The parameter `tagName` of this provider.
|
||||||
|
String get tagName;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TagBookmarksRequestProviderElement
|
||||||
|
extends AutoDisposeFutureProviderElement<ApiResponse<BookmarksResponse>>
|
||||||
|
with TagBookmarksRequestRef {
|
||||||
|
_TagBookmarksRequestProviderElement(super.provider);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get tagName => (origin as TagBookmarksRequestProvider).tagName;
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$tagBookmarksHash() => r'bcfcc986b8d58ccff54ed6dec3ab2a1a8c33a4f7';
|
||||||
|
|
||||||
|
/// See also [TagBookmarks].
|
||||||
|
@ProviderFor(TagBookmarks)
|
||||||
|
final tagBookmarksProvider =
|
||||||
|
AutoDisposeNotifierProvider<TagBookmarks, TagBookmarksModel>.internal(
|
||||||
|
TagBookmarks.new,
|
||||||
|
name: r'tagBookmarksProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product') ? null : _$tagBookmarksHash,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef _$TagBookmarks = AutoDisposeNotifier<TagBookmarksModel>;
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||||
85
lib/screens/tag_bookmarks/ui/tag_bookmarks.dart
Normal file
85
lib/screens/tag_bookmarks/ui/tag_bookmarks.dart
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
|
import 'package:linkdy/screens/bookmarks/ui/bookmark_item.dart';
|
||||||
|
import 'package:linkdy/screens/tag_bookmarks/provider/tag_bookmarks.provider.dart';
|
||||||
|
import 'package:linkdy/widgets/error_screen.dart';
|
||||||
|
import 'package:linkdy/widgets/no_data_screen.dart';
|
||||||
|
|
||||||
|
import 'package:linkdy/i18n/strings.g.dart';
|
||||||
|
import 'package:linkdy/models/data/tags.dart';
|
||||||
|
|
||||||
|
class TagBookmarksScreen extends ConsumerWidget {
|
||||||
|
final Tag tag;
|
||||||
|
|
||||||
|
const TagBookmarksScreen({
|
||||||
|
Key? key,
|
||||||
|
required this.tag,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final bookmarks = ref.watch(tagBookmarksRequestProvider(tag.name!));
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
body: NestedScrollView(
|
||||||
|
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
||||||
|
SliverOverlapAbsorber(
|
||||||
|
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||||
|
sliver: SliverAppBar.large(
|
||||||
|
pinned: true,
|
||||||
|
floating: true,
|
||||||
|
centerTitle: false,
|
||||||
|
forceElevated: innerBoxIsScrolled,
|
||||||
|
title: Text(tag.name!),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
body: SafeArea(
|
||||||
|
top: false,
|
||||||
|
bottom: false,
|
||||||
|
child: Builder(
|
||||||
|
builder: (context) => RefreshIndicator(
|
||||||
|
displacement: 120,
|
||||||
|
onRefresh: () => ref.refresh(tagBookmarksRequestProvider(tag.name!).future),
|
||||||
|
child: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
SliverOverlapInjector(
|
||||||
|
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||||
|
),
|
||||||
|
if (bookmarks.isLoading && !bookmarks.isRefreshing)
|
||||||
|
const SliverFillRemaining(
|
||||||
|
child: Center(child: CircularProgressIndicator()),
|
||||||
|
),
|
||||||
|
if (bookmarks.value != null && bookmarks.value!.successful == false)
|
||||||
|
SliverFillRemaining(
|
||||||
|
child: ErrorScreen(
|
||||||
|
error: t.bookmarks.cannotLoadBookmarks,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (bookmarks.value != null &&
|
||||||
|
bookmarks.value!.successful == true &&
|
||||||
|
bookmarks.value!.content!.results!.isEmpty)
|
||||||
|
SliverFillRemaining(
|
||||||
|
child: NoDataScreen(
|
||||||
|
message: t.tags.tagBookmarks.noBookmarksWithThisTag,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (bookmarks.value != null &&
|
||||||
|
bookmarks.value!.successful == true &&
|
||||||
|
bookmarks.value!.content!.results!.isNotEmpty)
|
||||||
|
SliverList.builder(
|
||||||
|
itemCount: bookmarks.value!.content!.results!.length,
|
||||||
|
itemBuilder: (context, index) => BookmarkItem(
|
||||||
|
bookmark: bookmarks.value!.content!.results![index],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:linkdy/providers/router_provider.dart';
|
||||||
|
import 'package:linkdy/router/names.dart';
|
||||||
|
|
||||||
import 'package:linkdy/screens/tags/provider/tags.provider.dart';
|
import 'package:linkdy/screens/tags/provider/tags.provider.dart';
|
||||||
import 'package:linkdy/screens/tags/ui/add_tag_modal.dart';
|
import 'package:linkdy/screens/tags/ui/add_tag_modal.dart';
|
||||||
@@ -78,7 +80,11 @@ class TagsScreen extends ConsumerWidget {
|
|||||||
}
|
}
|
||||||
final tag = tags.value?.content?.results?[index];
|
final tag = tags.value?.content?.results?[index];
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () => {},
|
onTap: () => ref.watch(routerProvider).pushNamed(
|
||||||
|
RoutesNames.tagBookmarks,
|
||||||
|
extra: tag,
|
||||||
|
pathParameters: {'id': tag.id!.toString()},
|
||||||
|
),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class ApiClientService {
|
|||||||
Future<ApiResponse<BookmarksResponse>> fetchBookmarks({String? q, int? limit, int? offset}) async {
|
Future<ApiResponse<BookmarksResponse>> fetchBookmarks({String? q, int? limit, int? offset}) async {
|
||||||
try {
|
try {
|
||||||
final response = await dioInstance.get(
|
final response = await dioInstance.get(
|
||||||
"/bookmarks",
|
"/bookmarks/",
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
"q": q,
|
"q": q,
|
||||||
"limit": limit,
|
"limit": limit,
|
||||||
|
|||||||
Reference in New Issue
Block a user