Renamed links to bookmarks
This commit is contained in:
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:linkdy/constants/enums.dart';
|
||||
import 'package:linkdy/models/data/check_bookmark.dart';
|
||||
|
||||
class AddLinkModel {
|
||||
class AddBookmarkModel {
|
||||
final TextEditingController urlController;
|
||||
String? urlError;
|
||||
CheckBookmark? checkBookmark;
|
||||
@@ -16,7 +16,7 @@ class AddLinkModel {
|
||||
List<String> tags;
|
||||
final TextEditingController notesController;
|
||||
|
||||
AddLinkModel({
|
||||
AddBookmarkModel({
|
||||
required this.urlController,
|
||||
this.urlError,
|
||||
this.checkBookmark,
|
||||
@@ -1,8 +1,8 @@
|
||||
class LinksModel {
|
||||
class BookmarksModel {
|
||||
int currentPage;
|
||||
int limit;
|
||||
|
||||
LinksModel({
|
||||
BookmarksModel({
|
||||
this.currentPage = 0,
|
||||
this.limit = 100,
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'package:linkdy/screens/links/provider/links.provider.dart';
|
||||
import 'package:linkdy/screens/links/model/add_link.model.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/bookmarks.provider.dart';
|
||||
import 'package:linkdy/screens/bookmarks/model/add_link.model.dart';
|
||||
|
||||
import 'package:linkdy/models/data/tags.dart';
|
||||
import 'package:linkdy/utils/snackbar.dart';
|
||||
@@ -10,14 +10,13 @@ import 'package:linkdy/i18n/strings.g.dart';
|
||||
import 'package:linkdy/utils/process_modal.dart';
|
||||
import 'package:linkdy/models/data/post_bookmark.dart';
|
||||
import 'package:linkdy/providers/router_provider.dart';
|
||||
import 'package:linkdy/models/data/bookmarks.dart';
|
||||
import 'package:linkdy/constants/enums.dart';
|
||||
import 'package:linkdy/constants/regexp.dart';
|
||||
import 'package:linkdy/models/api_response.dart';
|
||||
import 'package:linkdy/models/data/check_bookmark.dart';
|
||||
import 'package:linkdy/providers/api_client_provider.dart';
|
||||
|
||||
part 'add_link.provider.g.dart';
|
||||
part 'add_bookmark.provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
Future<ApiResponse<CheckBookmark>> checkBookmark(CheckBookmarkRef ref, String url) async {
|
||||
@@ -26,22 +25,16 @@ Future<ApiResponse<CheckBookmark>> checkBookmark(CheckBookmarkRef ref, String ur
|
||||
}
|
||||
|
||||
@riverpod
|
||||
FutureOr<ApiResponse<Bookmark>> addBookmark(AddBookmarkRef ref, PostBookmark newBookmark) async {
|
||||
final result = await ref.watch(apiClientProvider)!.fetchPostBookmark(newBookmark);
|
||||
return result;
|
||||
}
|
||||
|
||||
@riverpod
|
||||
FutureOr<ApiResponse<Tags>> getTags(GetTagsRef ref) async {
|
||||
FutureOr<ApiResponse<TagsResponse>> getTags(GetTagsRef ref) async {
|
||||
final result = await ref.watch(apiClientProvider)!.fetchTags();
|
||||
return result;
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class AddLink extends _$AddLink {
|
||||
class AddBookmark extends _$AddBookmark {
|
||||
@override
|
||||
AddLinkModel build() {
|
||||
return AddLinkModel(
|
||||
AddBookmarkModel build() {
|
||||
return AddBookmarkModel(
|
||||
urlController: TextEditingController(),
|
||||
titleController: TextEditingController(),
|
||||
descriptionController: TextEditingController(),
|
||||
@@ -58,7 +51,7 @@ class AddLink extends _$AddLink {
|
||||
state.urlError = null;
|
||||
ref.notifyListeners();
|
||||
} else {
|
||||
state.urlError = t.links.addLink.invalidUrl;
|
||||
state.urlError = t.bookmarks.addBookmark.invalidUrl;
|
||||
ref.notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -98,18 +91,18 @@ class AddLink extends _$AddLink {
|
||||
);
|
||||
|
||||
final processModal = ProcessModal();
|
||||
processModal.open(t.links.addLink.savingLink);
|
||||
processModal.open(t.bookmarks.addBookmark.savingBookmark);
|
||||
|
||||
final result = await ref.watch(addBookmarkProvider(newBookmark).future);
|
||||
final result = await ref.watch(apiClientProvider)!.fetchPostBookmark(newBookmark);
|
||||
|
||||
processModal.close();
|
||||
|
||||
if (result.successful == true) {
|
||||
ref.invalidate(linksRequestProvider);
|
||||
ref.invalidate(bookmarksRequestProvider);
|
||||
ref.watch(routerProvider).pop();
|
||||
} else {
|
||||
showSnacbkar(
|
||||
label: t.links.addLink.errorSavingLink,
|
||||
label: t.bookmarks.addBookmark.errorSavingBookmark,
|
||||
color: Colors.red,
|
||||
);
|
||||
}
|
||||
@@ -117,7 +110,7 @@ class AddLink extends _$AddLink {
|
||||
|
||||
void validateTagInput(String value) {
|
||||
if (value.contains(" ")) {
|
||||
state.tagsError = t.links.addLink.tagNoWhitespaces;
|
||||
state.tagsError = t.bookmarks.addBookmark.tagNoWhitespaces;
|
||||
} else {
|
||||
state.tagsError = null;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'add_link.provider.dart';
|
||||
part of 'add_bookmark.provider.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
@@ -160,141 +160,12 @@ class _CheckBookmarkProviderElement
|
||||
String get url => (origin as CheckBookmarkProvider).url;
|
||||
}
|
||||
|
||||
String _$addBookmarkHash() => r'f0994cdf9fe086431549dac44daadd367a8b801b';
|
||||
|
||||
/// See also [addBookmark].
|
||||
@ProviderFor(addBookmark)
|
||||
const addBookmarkProvider = AddBookmarkFamily();
|
||||
|
||||
/// See also [addBookmark].
|
||||
class AddBookmarkFamily extends Family<AsyncValue<ApiResponse<Bookmark>>> {
|
||||
/// See also [addBookmark].
|
||||
const AddBookmarkFamily();
|
||||
|
||||
/// See also [addBookmark].
|
||||
AddBookmarkProvider call(
|
||||
PostBookmark newBookmark,
|
||||
) {
|
||||
return AddBookmarkProvider(
|
||||
newBookmark,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
AddBookmarkProvider getProviderOverride(
|
||||
covariant AddBookmarkProvider provider,
|
||||
) {
|
||||
return call(
|
||||
provider.newBookmark,
|
||||
);
|
||||
}
|
||||
|
||||
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'addBookmarkProvider';
|
||||
}
|
||||
|
||||
/// See also [addBookmark].
|
||||
class AddBookmarkProvider
|
||||
extends AutoDisposeFutureProvider<ApiResponse<Bookmark>> {
|
||||
/// See also [addBookmark].
|
||||
AddBookmarkProvider(
|
||||
PostBookmark newBookmark,
|
||||
) : this._internal(
|
||||
(ref) => addBookmark(
|
||||
ref as AddBookmarkRef,
|
||||
newBookmark,
|
||||
),
|
||||
from: addBookmarkProvider,
|
||||
name: r'addBookmarkProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$addBookmarkHash,
|
||||
dependencies: AddBookmarkFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
AddBookmarkFamily._allTransitiveDependencies,
|
||||
newBookmark: newBookmark,
|
||||
);
|
||||
|
||||
AddBookmarkProvider._internal(
|
||||
super._createNotifier, {
|
||||
required super.name,
|
||||
required super.dependencies,
|
||||
required super.allTransitiveDependencies,
|
||||
required super.debugGetCreateSourceHash,
|
||||
required super.from,
|
||||
required this.newBookmark,
|
||||
}) : super.internal();
|
||||
|
||||
final PostBookmark newBookmark;
|
||||
|
||||
@override
|
||||
Override overrideWith(
|
||||
FutureOr<ApiResponse<Bookmark>> Function(AddBookmarkRef provider) create,
|
||||
) {
|
||||
return ProviderOverride(
|
||||
origin: this,
|
||||
override: AddBookmarkProvider._internal(
|
||||
(ref) => create(ref as AddBookmarkRef),
|
||||
from: from,
|
||||
name: null,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
debugGetCreateSourceHash: null,
|
||||
newBookmark: newBookmark,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
AutoDisposeFutureProviderElement<ApiResponse<Bookmark>> createElement() {
|
||||
return _AddBookmarkProviderElement(this);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is AddBookmarkProvider && other.newBookmark == newBookmark;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||
hash = _SystemHash.combine(hash, newBookmark.hashCode);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
}
|
||||
}
|
||||
|
||||
mixin AddBookmarkRef on AutoDisposeFutureProviderRef<ApiResponse<Bookmark>> {
|
||||
/// The parameter `newBookmark` of this provider.
|
||||
PostBookmark get newBookmark;
|
||||
}
|
||||
|
||||
class _AddBookmarkProviderElement
|
||||
extends AutoDisposeFutureProviderElement<ApiResponse<Bookmark>>
|
||||
with AddBookmarkRef {
|
||||
_AddBookmarkProviderElement(super.provider);
|
||||
|
||||
@override
|
||||
PostBookmark get newBookmark => (origin as AddBookmarkProvider).newBookmark;
|
||||
}
|
||||
|
||||
String _$getTagsHash() => r'22cfedf0f73a32c41992b922cbdfbb0145cccc9a';
|
||||
String _$getTagsHash() => r'16138d28ed9ee5b99f5c84935f7a1eb98fad2a3b';
|
||||
|
||||
/// See also [getTags].
|
||||
@ProviderFor(getTags)
|
||||
final getTagsProvider = AutoDisposeFutureProvider<ApiResponse<Tags>>.internal(
|
||||
final getTagsProvider =
|
||||
AutoDisposeFutureProvider<ApiResponse<TagsResponse>>.internal(
|
||||
getTags,
|
||||
name: r'getTagsProvider',
|
||||
debugGetCreateSourceHash:
|
||||
@@ -303,21 +174,21 @@ final getTagsProvider = AutoDisposeFutureProvider<ApiResponse<Tags>>.internal(
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef GetTagsRef = AutoDisposeFutureProviderRef<ApiResponse<Tags>>;
|
||||
String _$addLinkHash() => r'6a5c26a8e562236c7d3806bca869d932097fa6a6';
|
||||
typedef GetTagsRef = AutoDisposeFutureProviderRef<ApiResponse<TagsResponse>>;
|
||||
String _$addBookmarkHash() => r'2953a4223fe70809fbcf37af23b4f61a62f0de9f';
|
||||
|
||||
/// See also [AddLink].
|
||||
@ProviderFor(AddLink)
|
||||
final addLinkProvider =
|
||||
AutoDisposeNotifierProvider<AddLink, AddLinkModel>.internal(
|
||||
AddLink.new,
|
||||
name: r'addLinkProvider',
|
||||
/// See also [AddBookmark].
|
||||
@ProviderFor(AddBookmark)
|
||||
final addBookmarkProvider =
|
||||
AutoDisposeNotifierProvider<AddBookmark, AddBookmarkModel>.internal(
|
||||
AddBookmark.new,
|
||||
name: r'addBookmarkProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$addLinkHash,
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$addBookmarkHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$AddLink = AutoDisposeNotifier<AddLinkModel>;
|
||||
typedef _$AddBookmark = AutoDisposeNotifier<AddBookmarkModel>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||
@@ -1,24 +1,24 @@
|
||||
import 'package:linkdy/models/data/bookmarks.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'package:linkdy/screens/links/model/links.model.dart';
|
||||
import 'package:linkdy/screens/bookmarks/model/links.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 'links.provider.g.dart';
|
||||
part 'bookmarks.provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
FutureOr<ApiResponse<Bookmarks>> linksRequest(LinksRequestRef ref) async {
|
||||
FutureOr<ApiResponse<BookmarksResponse>> bookmarksRequest(BookmarksRequestRef ref) async {
|
||||
final result = await ref.watch(apiClientProvider)!.fetchBookmarks();
|
||||
return result;
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class Links extends _$Links {
|
||||
class Bookmarks extends _$Bookmarks {
|
||||
@override
|
||||
LinksModel build() {
|
||||
return LinksModel();
|
||||
BookmarksModel build() {
|
||||
return BookmarksModel();
|
||||
}
|
||||
|
||||
void setCurrentPage(int page) {
|
||||
42
lib/screens/bookmarks/provider/bookmarks.provider.g.dart
Normal file
42
lib/screens/bookmarks/provider/bookmarks.provider.g.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'bookmarks.provider.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$bookmarksRequestHash() => r'c80328ae148c39617997a44ac5c34f27daf25a8a';
|
||||
|
||||
/// See also [bookmarksRequest].
|
||||
@ProviderFor(bookmarksRequest)
|
||||
final bookmarksRequestProvider =
|
||||
AutoDisposeFutureProvider<ApiResponse<BookmarksResponse>>.internal(
|
||||
bookmarksRequest,
|
||||
name: r'bookmarksRequestProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$bookmarksRequestHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef BookmarksRequestRef
|
||||
= AutoDisposeFutureProviderRef<ApiResponse<BookmarksResponse>>;
|
||||
String _$bookmarksHash() => r'4a1726830b4e7bbc131d69761aeb4702ca6b7180';
|
||||
|
||||
/// See also [Bookmarks].
|
||||
@ProviderFor(Bookmarks)
|
||||
final bookmarksProvider =
|
||||
AutoDisposeNotifierProvider<Bookmarks, BookmarksModel>.internal(
|
||||
Bookmarks.new,
|
||||
name: r'bookmarksProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$bookmarksHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$Bookmarks = AutoDisposeNotifier<BookmarksModel>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||
@@ -2,16 +2,16 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:easy_autocomplete/easy_autocomplete.dart';
|
||||
|
||||
import 'package:linkdy/screens/links/provider/add_link.provider.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/add_bookmark.provider.dart';
|
||||
import 'package:linkdy/widgets/section_label.dart';
|
||||
|
||||
import 'package:linkdy/i18n/strings.g.dart';
|
||||
import 'package:linkdy/constants/enums.dart';
|
||||
|
||||
class AddLinkModal extends ConsumerWidget {
|
||||
class AddBookmarkModal extends ConsumerWidget {
|
||||
final bool fullscreen;
|
||||
|
||||
const AddLinkModal({
|
||||
const AddBookmarkModal({
|
||||
Key? key,
|
||||
required this.fullscreen,
|
||||
}) : super(key: key);
|
||||
@@ -24,11 +24,11 @@ class AddLinkModal extends ConsumerWidget {
|
||||
leading: CloseButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: Text(t.links.addLink.addLink),
|
||||
title: Text(t.bookmarks.addBookmark.addBookmark),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: ref.watch(addLinkProvider).checkBookmark != null
|
||||
? () => ref.read(addLinkProvider.notifier).addBookmark()
|
||||
onPressed: ref.watch(addBookmarkProvider).checkBookmark != null
|
||||
? () => ref.read(addBookmarkProvider.notifier).addBookmark()
|
||||
: null,
|
||||
icon: const Icon(Icons.save_rounded),
|
||||
tooltip: t.generic.save,
|
||||
@@ -47,7 +47,7 @@ class _ModalContent extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final provider = ref.watch(addLinkProvider);
|
||||
final provider = ref.watch(addBookmarkProvider);
|
||||
|
||||
final tags = ref.watch(getTagsProvider);
|
||||
|
||||
@@ -55,7 +55,7 @@ class _ModalContent extends ConsumerWidget {
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
SectionLabel(
|
||||
label: t.links.addLink.bookmarkUrl,
|
||||
label: t.bookmarks.addBookmark.bookmarkUrl,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 0,
|
||||
@@ -66,7 +66,7 @@ class _ModalContent extends ConsumerWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: TextFormField(
|
||||
controller: provider.urlController,
|
||||
onChanged: ref.read(addLinkProvider.notifier).validateUrl,
|
||||
onChanged: ref.read(addBookmarkProvider.notifier).validateUrl,
|
||||
enabled: provider.checkBookmarkLoadStatus != LoadStatus.loading,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.link_rounded),
|
||||
@@ -76,7 +76,7 @@ class _ModalContent extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
errorText: provider.urlError,
|
||||
labelText: t.links.addLink.url,
|
||||
labelText: t.bookmarks.addBookmark.url,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -88,7 +88,7 @@ class _ModalContent extends ConsumerWidget {
|
||||
onPressed: provider.checkBookmarkLoadStatus == null &&
|
||||
provider.urlError == null &&
|
||||
provider.urlController.text != ""
|
||||
? () => ref.read(addLinkProvider.notifier).checkUrlDetails()
|
||||
? () => ref.read(addBookmarkProvider.notifier).checkUrlDetails()
|
||||
: null,
|
||||
style: ButtonStyle(
|
||||
foregroundColor: provider.checkBookmarkLoadStatus == LoadStatus.loaded
|
||||
@@ -105,7 +105,7 @@ class _ModalContent extends ConsumerWidget {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (provider.checkBookmarkLoadStatus == null) Text(t.links.addLink.validateUrl),
|
||||
if (provider.checkBookmarkLoadStatus == null) Text(t.bookmarks.addBookmark.validateUrl),
|
||||
if (provider.checkBookmarkLoadStatus == LoadStatus.loading) ...[
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
@@ -115,17 +115,17 @@ class _ModalContent extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(t.links.addLink.checkingUrl),
|
||||
Text(t.bookmarks.addBookmark.checkingUrl),
|
||||
],
|
||||
if (provider.checkBookmarkLoadStatus == LoadStatus.loaded) ...[
|
||||
const Icon(Icons.check_circle_rounded),
|
||||
const SizedBox(width: 8),
|
||||
Text(t.links.addLink.urlValid),
|
||||
Text(t.bookmarks.addBookmark.urlValid),
|
||||
],
|
||||
if (provider.checkBookmarkLoadStatus == LoadStatus.error) ...[
|
||||
const Icon(Icons.error_rounded),
|
||||
const SizedBox(width: 8),
|
||||
Text(t.links.addLink.cannotCheckUrl),
|
||||
Text(t.bookmarks.addBookmark.cannotCheckUrl),
|
||||
],
|
||||
],
|
||||
),
|
||||
@@ -133,7 +133,7 @@ class _ModalContent extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
SectionLabel(
|
||||
label: t.links.addLink.bookmarkDetails,
|
||||
label: t.bookmarks.addBookmark.bookmarkDetails,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 24,
|
||||
@@ -150,11 +150,11 @@ class _ModalContent extends ConsumerWidget {
|
||||
Radius.circular(10),
|
||||
),
|
||||
),
|
||||
labelText: t.links.addLink.title,
|
||||
labelText: t.bookmarks.addBookmark.title,
|
||||
hintText: provider.checkBookmark?.metadata?.title,
|
||||
floatingLabelBehavior:
|
||||
provider.checkBookmark != null ? FloatingLabelBehavior.always : FloatingLabelBehavior.auto,
|
||||
helperText: t.links.addLink.leaveEmptyUseWebsiteTitle,
|
||||
helperText: t.bookmarks.addBookmark.leaveEmptyUseWebsiteTitle,
|
||||
enabled: provider.checkBookmark != null,
|
||||
),
|
||||
),
|
||||
@@ -171,17 +171,17 @@ class _ModalContent extends ConsumerWidget {
|
||||
Radius.circular(10),
|
||||
),
|
||||
),
|
||||
labelText: t.links.addLink.description,
|
||||
labelText: t.bookmarks.addBookmark.description,
|
||||
hintText: provider.checkBookmark?.metadata?.description,
|
||||
floatingLabelBehavior:
|
||||
provider.checkBookmark != null ? FloatingLabelBehavior.always : FloatingLabelBehavior.auto,
|
||||
helperText: t.links.addLink.leaveEmptyUseWebsiteDescription,
|
||||
helperText: t.bookmarks.addBookmark.leaveEmptyUseWebsiteDescription,
|
||||
enabled: provider.checkBookmark != null,
|
||||
),
|
||||
),
|
||||
),
|
||||
SectionLabel(
|
||||
label: t.links.addLink.tags,
|
||||
label: t.bookmarks.addBookmark.tags,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 24,
|
||||
@@ -198,7 +198,7 @@ class _ModalContent extends ConsumerWidget {
|
||||
Expanded(
|
||||
child: EasyAutocomplete(
|
||||
controller: provider.tagsController,
|
||||
onChanged: ref.read(addLinkProvider.notifier).validateTagInput,
|
||||
onChanged: ref.read(addBookmarkProvider.notifier).validateTagInput,
|
||||
suggestions: tags.value?.content?.results?.map((t) => t.name!).toList() ?? [],
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(
|
||||
@@ -206,7 +206,7 @@ class _ModalContent extends ConsumerWidget {
|
||||
Radius.circular(10),
|
||||
),
|
||||
),
|
||||
labelText: t.links.addLink.tags,
|
||||
labelText: t.bookmarks.addBookmark.tags,
|
||||
errorText: provider.tagsError,
|
||||
),
|
||||
suggestionBuilder: (data) => Padding(
|
||||
@@ -218,8 +218,8 @@ class _ModalContent extends ConsumerWidget {
|
||||
),
|
||||
onSubmitted: provider.tagsController.text != "" && provider.tagsError == null
|
||||
? (v) {
|
||||
ref.read(addLinkProvider.notifier).setTags([...provider.tags, v]);
|
||||
ref.read(addLinkProvider.notifier).clearTagsController();
|
||||
ref.read(addBookmarkProvider.notifier).setTags([...provider.tags, v]);
|
||||
ref.read(addBookmarkProvider.notifier).clearTagsController();
|
||||
}
|
||||
: null,
|
||||
),
|
||||
@@ -229,13 +229,13 @@ class _ModalContent extends ConsumerWidget {
|
||||
onPressed: provider.tagsController.text != "" && provider.tagsError == null
|
||||
? () {
|
||||
ref
|
||||
.read(addLinkProvider.notifier)
|
||||
.read(addBookmarkProvider.notifier)
|
||||
.setTags([...provider.tags, provider.tagsController.text]);
|
||||
ref.read(addLinkProvider.notifier).clearTagsController();
|
||||
ref.read(addBookmarkProvider.notifier).clearTagsController();
|
||||
}
|
||||
: null,
|
||||
icon: const Icon(Icons.check_rounded),
|
||||
tooltip: t.links.addLink.addTag,
|
||||
tooltip: t.bookmarks.addBookmark.addTag,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -250,13 +250,13 @@ class _ModalContent extends ConsumerWidget {
|
||||
itemBuilder: (context, index) => InputChip(
|
||||
label: Text(provider.tags[index]),
|
||||
onDeleted: () => ref
|
||||
.read(addLinkProvider.notifier)
|
||||
.read(addBookmarkProvider.notifier)
|
||||
.setTags(provider.tags.where((tag) => tag != provider.tags[index]).toList()),
|
||||
),
|
||||
)
|
||||
: Center(
|
||||
child: Text(
|
||||
t.links.addLink.noTagsAdded,
|
||||
t.bookmarks.addBookmark.noTagsAdded,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
@@ -268,7 +268,7 @@ class _ModalContent extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
SectionLabel(
|
||||
label: t.links.addLink.others,
|
||||
label: t.bookmarks.addBookmark.others,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 24,
|
||||
@@ -287,7 +287,7 @@ class _ModalContent extends ConsumerWidget {
|
||||
Radius.circular(10),
|
||||
),
|
||||
),
|
||||
labelText: t.links.addLink.notes,
|
||||
labelText: t.bookmarks.addBookmark.notes,
|
||||
helperText: t.generic.optional,
|
||||
),
|
||||
autocorrect: false,
|
||||
@@ -302,10 +302,11 @@ class _ModalContent extends ConsumerWidget {
|
||||
const SizedBox(height: 12),
|
||||
SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
title: Text(t.links.addLink.markAsUnread),
|
||||
title: Text(t.bookmarks.addBookmark.markAsUnread),
|
||||
value: provider.markAsUnread,
|
||||
onChanged:
|
||||
provider.checkBookmark != null ? (v) => ref.read(addLinkProvider.notifier).updateMarkAsUnread(v) : null,
|
||||
onChanged: provider.checkBookmark != null
|
||||
? (v) => ref.read(addBookmarkProvider.notifier).updateMarkAsUnread(v)
|
||||
: null,
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -3,23 +3,18 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:linkdy/screens/links/provider/links.provider.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/bookmarks.provider.dart';
|
||||
import 'package:linkdy/screens/bookmarks/ui/bookmark_item.dart';
|
||||
import 'package:linkdy/screens/bookmarks/ui/add_bookmark_modal.dart';
|
||||
|
||||
import 'package:linkdy/screens/links/ui/add_link_modal.dart';
|
||||
|
||||
import 'package:linkdy/providers/app_status_provider.dart';
|
||||
import 'package:linkdy/providers/router_provider.dart';
|
||||
import 'package:linkdy/router/paths.dart';
|
||||
import 'package:linkdy/i18n/strings.g.dart';
|
||||
import 'package:linkdy/screens/links/ui/link_item.dart';
|
||||
import 'package:linkdy/utils/open_url.dart';
|
||||
|
||||
class Links extends ConsumerWidget {
|
||||
const Links({Key? key}) : super(key: key);
|
||||
class BookmarksScreen extends ConsumerWidget {
|
||||
const BookmarksScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final bookmarks = ref.watch(linksRequestProvider);
|
||||
final bookmarks = ref.watch(bookmarksRequestProvider);
|
||||
|
||||
final width = MediaQuery.of(context).size.width;
|
||||
|
||||
@@ -35,7 +30,7 @@ class Links extends ConsumerWidget {
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
pageBuilder: (context, animation, secondaryAnimation) => AddLinkModal(fullscreen: width <= 700),
|
||||
pageBuilder: (context, animation, secondaryAnimation) => AddBookmarkModal(fullscreen: width <= 700),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -49,7 +44,7 @@ class Links extends ConsumerWidget {
|
||||
floating: true,
|
||||
centerTitle: false,
|
||||
forceElevated: innerBoxIsScrolled,
|
||||
title: Text(t.links.links),
|
||||
title: Text(t.bookmarks.bookmarks),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -59,7 +54,7 @@ class Links extends ConsumerWidget {
|
||||
child: Builder(
|
||||
builder: (context) => RefreshIndicator(
|
||||
displacement: 120,
|
||||
onRefresh: () => ref.refresh(linksRequestProvider.future),
|
||||
onRefresh: () => ref.refresh(bookmarksRequestProvider.future),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
SliverOverlapInjector(
|
||||
@@ -1,39 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'links.provider.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$linksRequestHash() => r'2bc6cb36d7c7090f5328c48e1f71acd46df5303b';
|
||||
|
||||
/// See also [linksRequest].
|
||||
@ProviderFor(linksRequest)
|
||||
final linksRequestProvider =
|
||||
AutoDisposeFutureProvider<ApiResponse<Bookmarks>>.internal(
|
||||
linksRequest,
|
||||
name: r'linksRequestProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$linksRequestHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef LinksRequestRef = AutoDisposeFutureProviderRef<ApiResponse<Bookmarks>>;
|
||||
String _$linksHash() => r'a609009ca33885b1efd0d7c1122bee8299b98af3';
|
||||
|
||||
/// See also [Links].
|
||||
@ProviderFor(Links)
|
||||
final linksProvider = AutoDisposeNotifierProvider<Links, LinksModel>.internal(
|
||||
Links.new,
|
||||
name: r'linksProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$linksHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$Links = AutoDisposeNotifier<LinksModel>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||
@@ -11,14 +11,14 @@ import 'package:linkdy/providers/api_client_provider.dart';
|
||||
part 'search.provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
FutureOr<ApiResponse<Bookmarks>?> searchBookmarks(SearchBookmarksRef ref) async {
|
||||
FutureOr<ApiResponse<BookmarksResponse>?> searchBookmarks(SearchBookmarksRef ref) async {
|
||||
if (ref.watch(searchProvider).searchTerm == "") return null;
|
||||
final result = await ref.read(apiClientProvider)!.fetchBookmarks(q: ref.watch(searchProvider).searchTerm);
|
||||
return result;
|
||||
}
|
||||
|
||||
@riverpod
|
||||
FutureOr<ApiResponse<Tags>?> searchTags(SearchTagsRef ref) async {
|
||||
FutureOr<ApiResponse<TagsResponse>?> searchTags(SearchTagsRef ref) async {
|
||||
if (ref.watch(searchProvider).searchTerm == "") return null;
|
||||
final result = await ref.read(apiClientProvider)!.fetchTags(q: ref.watch(searchProvider).searchTerm);
|
||||
return result;
|
||||
|
||||
@@ -6,12 +6,12 @@ part of 'search.provider.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$searchBookmarksHash() => r'c8d0bfb69cc6c295649a8e2d90f57352689cdab7';
|
||||
String _$searchBookmarksHash() => r'301f5c0355044978b6ddcfa13478b8729773f290';
|
||||
|
||||
/// See also [searchBookmarks].
|
||||
@ProviderFor(searchBookmarks)
|
||||
final searchBookmarksProvider =
|
||||
AutoDisposeFutureProvider<ApiResponse<Bookmarks>?>.internal(
|
||||
AutoDisposeFutureProvider<ApiResponse<BookmarksResponse>?>.internal(
|
||||
searchBookmarks,
|
||||
name: r'searchBookmarksProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
@@ -22,13 +22,13 @@ final searchBookmarksProvider =
|
||||
);
|
||||
|
||||
typedef SearchBookmarksRef
|
||||
= AutoDisposeFutureProviderRef<ApiResponse<Bookmarks>?>;
|
||||
String _$searchTagsHash() => r'6af31fef1a5020612f098550d54939852d88e187';
|
||||
= AutoDisposeFutureProviderRef<ApiResponse<BookmarksResponse>?>;
|
||||
String _$searchTagsHash() => r'1fc8cf44f512490fcf369b843bf3ca137e867bb6';
|
||||
|
||||
/// See also [searchTags].
|
||||
@ProviderFor(searchTags)
|
||||
final searchTagsProvider =
|
||||
AutoDisposeFutureProvider<ApiResponse<Tags>?>.internal(
|
||||
AutoDisposeFutureProvider<ApiResponse<TagsResponse>?>.internal(
|
||||
searchTags,
|
||||
name: r'searchTagsProvider',
|
||||
debugGetCreateSourceHash:
|
||||
@@ -37,7 +37,8 @@ final searchTagsProvider =
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef SearchTagsRef = AutoDisposeFutureProviderRef<ApiResponse<Tags>?>;
|
||||
typedef SearchTagsRef
|
||||
= AutoDisposeFutureProviderRef<ApiResponse<TagsResponse>?>;
|
||||
String _$searchHash() => r'bdb992f3343d912d9422fa5da14ad0d5704f18e7';
|
||||
|
||||
/// See also [Search].
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:linkdy/screens/search/ui/error_search_list.dart';
|
||||
import 'package:linkdy/screens/search/ui/input_search_term.dart';
|
||||
import 'package:linkdy/screens/links/ui/link_item.dart';
|
||||
import 'package:linkdy/screens/bookmarks/ui/bookmark_item.dart';
|
||||
import 'package:linkdy/screens/search/provider/search.provider.dart';
|
||||
import 'package:linkdy/screens/search/ui/search_no_data.dart';
|
||||
import 'package:linkdy/widgets/sliver_tab_body.dart';
|
||||
|
||||
@@ -71,7 +71,7 @@ class SearchState extends ConsumerState<Search> with TickerProviderStateMixin {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.link_rounded),
|
||||
const Icon(Icons.bookmarks_rounded),
|
||||
const SizedBox(width: 8),
|
||||
Text(t.search.bookmarks),
|
||||
],
|
||||
@@ -81,7 +81,7 @@ class SearchState extends ConsumerState<Search> with TickerProviderStateMixin {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.tag_rounded),
|
||||
const Icon(Icons.label_rounded),
|
||||
const SizedBox(width: 8),
|
||||
Text(t.search.tags),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user