Rise fabs when snackbar is shown
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/// Locales: 2
|
/// Locales: 2
|
||||||
/// Strings: 280 (140 per locale)
|
/// Strings: 280 (140 per locale)
|
||||||
///
|
///
|
||||||
/// Built on 2024-02-25 at 20:58 UTC
|
/// Built on 2024-02-26 at 09:50 UTC
|
||||||
|
|
||||||
// coverage:ignore-file
|
// coverage:ignore-file
|
||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
|
|||||||
7
lib/models/providers_models/snackbar_status.model.dart
Normal file
7
lib/models/providers_models/snackbar_status.model.dart
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
class SnackbarStatusModel {
|
||||||
|
bool visible;
|
||||||
|
|
||||||
|
SnackbarStatusModel({
|
||||||
|
this.visible = false,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|||||||
|
|
||||||
import 'package:linkdy/providers/shared_preferences.provider.dart';
|
import 'package:linkdy/providers/shared_preferences.provider.dart';
|
||||||
import 'package:linkdy/constants/enums.dart';
|
import 'package:linkdy/constants/enums.dart';
|
||||||
import 'package:linkdy/models/app_status.dart';
|
import 'package:linkdy/models/providers_models/app_status.model.dart';
|
||||||
|
|
||||||
part 'app_status.provider.g.dart';
|
part 'app_status.provider.g.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
|
import 'package:linkdy/providers/snackbar.provider.dart';
|
||||||
import 'package:linkdy/i18n/strings.g.dart';
|
import 'package:linkdy/i18n/strings.g.dart';
|
||||||
import 'package:linkdy/providers/server_instances.provider.dart';
|
import 'package:linkdy/providers/server_instances.provider.dart';
|
||||||
import 'package:linkdy/router/routes.dart';
|
import 'package:linkdy/router/routes.dart';
|
||||||
import 'package:linkdy/utils/snackbar.dart';
|
|
||||||
import 'package:linkdy/router/paths.dart';
|
import 'package:linkdy/router/paths.dart';
|
||||||
import 'package:linkdy/providers/api_client.provider.dart';
|
import 'package:linkdy/providers/api_client.provider.dart';
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ InterceptorsWrapper dioInterceptor(DioInterceptorRef ref) {
|
|||||||
GoRouter.of(rootNavigatorKey.currentContext!).pushReplacement(RoutesPaths.onboarding);
|
GoRouter.of(rootNavigatorKey.currentContext!).pushReplacement(RoutesPaths.onboarding);
|
||||||
ref.read(apiClientProvider.notifier).disconnectApiClient();
|
ref.read(apiClientProvider.notifier).disconnectApiClient();
|
||||||
ref.read(serverInstancesProvider.notifier).removeServerInstances();
|
ref.read(serverInstancesProvider.notifier).removeServerInstances();
|
||||||
showSnacbkar(label: t.generic.authTokenNotValid, color: Colors.red);
|
ref.read(snackbarProvider.notifier).showSnacbkar(label: t.generic.authTokenNotValid, color: Colors.red);
|
||||||
}
|
}
|
||||||
handler.next(error);
|
handler.next(error);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ part of 'dio_interceptor.provider.dart';
|
|||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$dioInterceptorHash() => r'449d19df5bf143a7e0f92249d99b4d223b2468f3';
|
String _$dioInterceptorHash() => r'15186eb74bde12048a96b1d38f1c9308c9f435a8';
|
||||||
|
|
||||||
/// See also [dioInterceptor].
|
/// See also [dioInterceptor].
|
||||||
@ProviderFor(dioInterceptor)
|
@ProviderFor(dioInterceptor)
|
||||||
|
|||||||
42
lib/providers/snackbar.provider.dart
Normal file
42
lib/providers/snackbar.provider.dart
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
|
import 'package:linkdy/constants/global_keys.dart';
|
||||||
|
import 'package:linkdy/models/providers_models/snackbar_status.model.dart';
|
||||||
|
|
||||||
|
part 'snackbar.provider.g.dart';
|
||||||
|
|
||||||
|
@Riverpod(keepAlive: true)
|
||||||
|
class Snackbar extends _$Snackbar {
|
||||||
|
@override
|
||||||
|
SnackbarStatusModel build() {
|
||||||
|
return SnackbarStatusModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void showSnacbkar({
|
||||||
|
required String label,
|
||||||
|
required Color color,
|
||||||
|
Color? labelColor,
|
||||||
|
GlobalKey<ScaffoldMessengerState>? key,
|
||||||
|
}) async {
|
||||||
|
final GlobalKey<ScaffoldMessengerState> scaffoldKey = key ?? scaffoldMessengerGlobalKey;
|
||||||
|
if (state.visible == true) {
|
||||||
|
scaffoldKey.currentState?.clearSnackBars();
|
||||||
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
|
}
|
||||||
|
state.visible = true;
|
||||||
|
ref.notifyListeners();
|
||||||
|
|
||||||
|
final snackBar = SnackBar(
|
||||||
|
content: Text(
|
||||||
|
label,
|
||||||
|
style: TextStyle(color: labelColor ?? Colors.white),
|
||||||
|
),
|
||||||
|
backgroundColor: color,
|
||||||
|
);
|
||||||
|
scaffoldKey.currentState?.showSnackBar(snackBar).closed.then((value) {
|
||||||
|
state.visible = false;
|
||||||
|
ref.notifyListeners();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
25
lib/providers/snackbar.provider.g.dart
Normal file
25
lib/providers/snackbar.provider.g.dart
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'snackbar.provider.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// RiverpodGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
String _$snackbarHash() => r'2522a7ebc0bdd891cea5cb342bd1ff2419473a00';
|
||||||
|
|
||||||
|
/// See also [Snackbar].
|
||||||
|
@ProviderFor(Snackbar)
|
||||||
|
final snackbarProvider =
|
||||||
|
NotifierProvider<Snackbar, SnackbarStatusModel>.internal(
|
||||||
|
Snackbar.new,
|
||||||
|
name: r'snackbarProvider',
|
||||||
|
debugGetCreateSourceHash:
|
||||||
|
const bool.fromEnvironment('dart.vm.product') ? null : _$snackbarHash,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef _$Snackbar = Notifier<SnackbarStatusModel>;
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||||
@@ -4,8 +4,8 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|||||||
import 'package:linkdy/screens/bookmarks/provider/bookmarks.provider.dart';
|
import 'package:linkdy/screens/bookmarks/provider/bookmarks.provider.dart';
|
||||||
import 'package:linkdy/screens/bookmarks/model/add_link.model.dart';
|
import 'package:linkdy/screens/bookmarks/model/add_link.model.dart';
|
||||||
|
|
||||||
|
import 'package:linkdy/providers/snackbar.provider.dart';
|
||||||
import 'package:linkdy/models/data/tags.dart';
|
import 'package:linkdy/models/data/tags.dart';
|
||||||
import 'package:linkdy/utils/snackbar.dart';
|
|
||||||
import 'package:linkdy/i18n/strings.g.dart';
|
import 'package:linkdy/i18n/strings.g.dart';
|
||||||
import 'package:linkdy/utils/process_modal.dart';
|
import 'package:linkdy/utils/process_modal.dart';
|
||||||
import 'package:linkdy/models/data/set_bookmark_data.dart';
|
import 'package:linkdy/models/data/set_bookmark_data.dart';
|
||||||
@@ -101,10 +101,10 @@ class AddBookmark extends _$AddBookmark {
|
|||||||
ref.read(bookmarksProvider.notifier).refresh();
|
ref.read(bookmarksProvider.notifier).refresh();
|
||||||
ref.watch(routerProvider).pop();
|
ref.watch(routerProvider).pop();
|
||||||
} else {
|
} else {
|
||||||
showSnacbkar(
|
ref.read(snackbarProvider.notifier).showSnacbkar(
|
||||||
label: t.bookmarks.addBookmark.errorSavingBookmark,
|
label: t.bookmarks.addBookmark.errorSavingBookmark,
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ final getTagsProvider =
|
|||||||
);
|
);
|
||||||
|
|
||||||
typedef GetTagsRef = AutoDisposeFutureProviderRef<ApiResponse<TagsResponse>>;
|
typedef GetTagsRef = AutoDisposeFutureProviderRef<ApiResponse<TagsResponse>>;
|
||||||
String _$addBookmarkHash() => r'510fe4dbdc6628a13be9d8c5c2581fd5ac94ca68';
|
String _$addBookmarkHash() => r'd6425004c3e755ec539ad28da3ef44349680b04b';
|
||||||
|
|
||||||
/// See also [AddBookmark].
|
/// See also [AddBookmark].
|
||||||
@ProviderFor(AddBookmark)
|
@ProviderFor(AddBookmark)
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ class Bookmarks extends _$Bookmarks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void deleteBookmark(Bookmark bookmark) async {
|
void deleteBookmark(Bookmark bookmark) async {
|
||||||
final result = await BookmarkCommonFunctions.deleteBookmark(
|
final result = await BookmarkCommonFunctions.deleteBookmark<BookmarksModel>(
|
||||||
|
ref: ref,
|
||||||
bookmark: bookmark,
|
bookmark: bookmark,
|
||||||
apiClient: ref.read(apiClientProvider)!,
|
apiClient: ref.read(apiClientProvider)!,
|
||||||
);
|
);
|
||||||
@@ -100,7 +101,8 @@ class Bookmarks extends _$Bookmarks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void markAsReadUnread(Bookmark bookmark) async {
|
void markAsReadUnread(Bookmark bookmark) async {
|
||||||
final result = await BookmarkCommonFunctions.markAsReadUnread(
|
final result = await BookmarkCommonFunctions.markAsReadUnread<BookmarksModel>(
|
||||||
|
ref: ref,
|
||||||
bookmark: bookmark,
|
bookmark: bookmark,
|
||||||
apiClient: ref.read(apiClientProvider)!,
|
apiClient: ref.read(apiClientProvider)!,
|
||||||
);
|
);
|
||||||
@@ -111,7 +113,8 @@ class Bookmarks extends _$Bookmarks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void archiveUnarchive(Bookmark bookmark) async {
|
void archiveUnarchive(Bookmark bookmark) async {
|
||||||
final result = await BookmarkCommonFunctions.markAsReadUnread(
|
final result = await BookmarkCommonFunctions.archiveUnarchive<BookmarksModel>(
|
||||||
|
ref: ref,
|
||||||
bookmark: bookmark,
|
bookmark: bookmark,
|
||||||
apiClient: ref.read(apiClientProvider)!,
|
apiClient: ref.read(apiClientProvider)!,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ final bookmarksRequestLoadMoreProvider =
|
|||||||
);
|
);
|
||||||
|
|
||||||
typedef BookmarksRequestLoadMoreRef = AutoDisposeFutureProviderRef<void>;
|
typedef BookmarksRequestLoadMoreRef = AutoDisposeFutureProviderRef<void>;
|
||||||
String _$bookmarksHash() => r'82c31fa1cbab1ba1e5c77486e7dc7ce5a86e20a5';
|
String _$bookmarksHash() => r'71282b9487a2e9d4a17973af7fb3da7c0171f8d0';
|
||||||
|
|
||||||
/// See also [Bookmarks].
|
/// See also [Bookmarks].
|
||||||
@ProviderFor(Bookmarks)
|
@ProviderFor(Bookmarks)
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:linkdy/providers/snackbar.provider.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
import 'package:linkdy/i18n/strings.g.dart';
|
import 'package:linkdy/i18n/strings.g.dart';
|
||||||
import 'package:linkdy/models/data/bookmarks.dart';
|
import 'package:linkdy/models/data/bookmarks.dart';
|
||||||
import 'package:linkdy/models/data/set_bookmark_data.dart';
|
import 'package:linkdy/models/data/set_bookmark_data.dart';
|
||||||
import 'package:linkdy/services/api_client.dart';
|
import 'package:linkdy/services/api_client.dart';
|
||||||
import 'package:linkdy/utils/process_modal.dart';
|
import 'package:linkdy/utils/process_modal.dart';
|
||||||
import 'package:linkdy/utils/snackbar.dart';
|
|
||||||
|
|
||||||
class BookmarkCommonFunctions {
|
class BookmarkCommonFunctions {
|
||||||
static Future<bool> deleteBookmark({
|
static Future<bool> deleteBookmark<T>({
|
||||||
|
required AutoDisposeNotifierProviderRef<T> ref,
|
||||||
required Bookmark bookmark,
|
required Bookmark bookmark,
|
||||||
required ApiClientService apiClient,
|
required ApiClientService apiClient,
|
||||||
}) async {
|
}) async {
|
||||||
@@ -19,14 +21,19 @@ class BookmarkCommonFunctions {
|
|||||||
|
|
||||||
processModal.close();
|
processModal.close();
|
||||||
if (result.successful == true) {
|
if (result.successful == true) {
|
||||||
showSnacbkar(label: t.bookmarks.bookmarkOptions.bookmarkDeleted, color: Colors.green);
|
ref
|
||||||
|
.read(snackbarProvider.notifier)
|
||||||
|
.showSnacbkar(label: t.bookmarks.bookmarkOptions.bookmarkDeleted, color: Colors.green);
|
||||||
} else {
|
} else {
|
||||||
showSnacbkar(label: t.bookmarks.bookmarkOptions.bookmarkNotDeleted, color: Colors.red);
|
ref
|
||||||
|
.read(snackbarProvider.notifier)
|
||||||
|
.showSnacbkar(label: t.bookmarks.bookmarkOptions.bookmarkNotDeleted, color: Colors.red);
|
||||||
}
|
}
|
||||||
return result.successful;
|
return result.successful;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<Bookmark?> markAsReadUnread({
|
static Future<Bookmark?> markAsReadUnread<T>({
|
||||||
|
required AutoDisposeNotifierProviderRef<T> ref,
|
||||||
required Bookmark bookmark,
|
required Bookmark bookmark,
|
||||||
required ApiClientService apiClient,
|
required ApiClientService apiClient,
|
||||||
}) async {
|
}) async {
|
||||||
@@ -50,25 +57,26 @@ class BookmarkCommonFunctions {
|
|||||||
|
|
||||||
processModal.close();
|
processModal.close();
|
||||||
if (result.successful == true) {
|
if (result.successful == true) {
|
||||||
showSnacbkar(
|
ref.read(snackbarProvider.notifier).showSnacbkar(
|
||||||
label: bookmark.unread == true
|
label: bookmark.unread == true
|
||||||
? t.bookmarks.bookmarkOptions.markedAsReadSuccessfully
|
? t.bookmarks.bookmarkOptions.markedAsReadSuccessfully
|
||||||
: t.bookmarks.bookmarkOptions.markedAsUnreadSuccessfully,
|
: t.bookmarks.bookmarkOptions.markedAsUnreadSuccessfully,
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
);
|
);
|
||||||
return result.content;
|
return result.content;
|
||||||
} else {
|
} else {
|
||||||
showSnacbkar(
|
ref.read(snackbarProvider.notifier).showSnacbkar(
|
||||||
label: bookmark.unread == true
|
label: bookmark.unread == true
|
||||||
? t.bookmarks.bookmarkOptions.bookmarkNotMarkedAsRead
|
? t.bookmarks.bookmarkOptions.bookmarkNotMarkedAsRead
|
||||||
: t.bookmarks.bookmarkOptions.bookmarkNotMarkedAsUnread,
|
: t.bookmarks.bookmarkOptions.bookmarkNotMarkedAsUnread,
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<Bookmark?> archiveUnarchive({
|
static Future<Bookmark?> archiveUnarchive<T>({
|
||||||
|
required AutoDisposeNotifierProviderRef<T> ref,
|
||||||
required Bookmark bookmark,
|
required Bookmark bookmark,
|
||||||
required ApiClientService apiClient,
|
required ApiClientService apiClient,
|
||||||
}) async {
|
}) async {
|
||||||
@@ -94,20 +102,20 @@ class BookmarkCommonFunctions {
|
|||||||
|
|
||||||
processModal.close();
|
processModal.close();
|
||||||
if (result.successful == true) {
|
if (result.successful == true) {
|
||||||
showSnacbkar(
|
ref.read(snackbarProvider.notifier).showSnacbkar(
|
||||||
label: bookmark.isArchived == true
|
label: bookmark.isArchived == true
|
||||||
? t.bookmarks.bookmarkOptions.bookmarkUnrchivedSuccessfully
|
? t.bookmarks.bookmarkOptions.bookmarkUnrchivedSuccessfully
|
||||||
: t.bookmarks.bookmarkOptions.bookmarkArchivedSuccessfully,
|
: t.bookmarks.bookmarkOptions.bookmarkArchivedSuccessfully,
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
);
|
);
|
||||||
return result.content;
|
return result.content;
|
||||||
} else {
|
} else {
|
||||||
showSnacbkar(
|
ref.read(snackbarProvider.notifier).showSnacbkar(
|
||||||
label: bookmark.isArchived == true
|
label: bookmark.isArchived == true
|
||||||
? t.bookmarks.bookmarkOptions.bookmarkNotUnrchived
|
? t.bookmarks.bookmarkOptions.bookmarkNotUnrchived
|
||||||
: t.bookmarks.bookmarkOptions.bookmarkNotArchived,
|
: t.bookmarks.bookmarkOptions.bookmarkNotArchived,
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ class SearchBookmarks extends _$SearchBookmarks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void deleteBookmark(Bookmark bookmark) async {
|
void deleteBookmark(Bookmark bookmark) async {
|
||||||
final result = await BookmarkCommonFunctions.deleteBookmark(
|
final result = await BookmarkCommonFunctions.deleteBookmark<SearchBookmarksModel>(
|
||||||
|
ref: ref,
|
||||||
bookmark: bookmark,
|
bookmark: bookmark,
|
||||||
apiClient: ref.read(apiClientProvider)!,
|
apiClient: ref.read(apiClientProvider)!,
|
||||||
);
|
);
|
||||||
@@ -113,7 +114,8 @@ class SearchBookmarks extends _$SearchBookmarks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void markAsReadUnread(Bookmark bookmark) async {
|
void markAsReadUnread(Bookmark bookmark) async {
|
||||||
final result = await BookmarkCommonFunctions.markAsReadUnread(
|
final result = await BookmarkCommonFunctions.markAsReadUnread<SearchBookmarksModel>(
|
||||||
|
ref: ref,
|
||||||
bookmark: bookmark,
|
bookmark: bookmark,
|
||||||
apiClient: ref.read(apiClientProvider)!,
|
apiClient: ref.read(apiClientProvider)!,
|
||||||
);
|
);
|
||||||
@@ -127,7 +129,8 @@ class SearchBookmarks extends _$SearchBookmarks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void archiveUnarchive(Bookmark bookmark) async {
|
void archiveUnarchive(Bookmark bookmark) async {
|
||||||
final result = await BookmarkCommonFunctions.markAsReadUnread(
|
final result = await BookmarkCommonFunctions.markAsReadUnread<SearchBookmarksModel>(
|
||||||
|
ref: ref,
|
||||||
bookmark: bookmark,
|
bookmark: bookmark,
|
||||||
apiClient: ref.read(apiClientProvider)!,
|
apiClient: ref.read(apiClientProvider)!,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ final fetchSearchBookmarksLoadMoreProvider =
|
|||||||
);
|
);
|
||||||
|
|
||||||
typedef FetchSearchBookmarksLoadMoreRef = AutoDisposeFutureProviderRef<void>;
|
typedef FetchSearchBookmarksLoadMoreRef = AutoDisposeFutureProviderRef<void>;
|
||||||
String _$searchBookmarksHash() => r'843fe597bceab3e3f512b5b4a40ddd1dbeb09f9d';
|
String _$searchBookmarksHash() => r'6e8eea2bf9c19b33f626e64ae74210d9b374065f';
|
||||||
|
|
||||||
/// See also [SearchBookmarks].
|
/// See also [SearchBookmarks].
|
||||||
@ProviderFor(SearchBookmarks)
|
@ProviderFor(SearchBookmarks)
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ import 'package:linkdy/screens/bookmarks/ui/add_bookmark_modal.dart';
|
|||||||
import 'package:linkdy/screens/bookmarks/ui/delete_bookmark_modal.dart';
|
import 'package:linkdy/screens/bookmarks/ui/delete_bookmark_modal.dart';
|
||||||
import 'package:linkdy/widgets/error_screen.dart';
|
import 'package:linkdy/widgets/error_screen.dart';
|
||||||
import 'package:linkdy/widgets/no_data_screen.dart';
|
import 'package:linkdy/widgets/no_data_screen.dart';
|
||||||
|
import 'package:linkdy/widgets/snackbar_fab.dart';
|
||||||
|
|
||||||
import 'package:linkdy/i18n/strings.g.dart';
|
import 'package:linkdy/i18n/strings.g.dart';
|
||||||
import 'package:linkdy/providers/router.provider.dart';
|
import 'package:linkdy/providers/router.provider.dart';
|
||||||
import 'package:linkdy/models/data/bookmarks.dart';
|
|
||||||
import 'package:linkdy/router/paths.dart';
|
import 'package:linkdy/router/paths.dart';
|
||||||
|
|
||||||
class BookmarksScreen extends ConsumerWidget {
|
class BookmarksScreen extends ConsumerWidget {
|
||||||
@@ -42,8 +42,6 @@ class BookmarksScreen extends ConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void openDeleteBookmarkModal(Bookmark bookmark) {}
|
|
||||||
|
|
||||||
bool scrollListener(ScrollUpdateNotification scrollNotification) {
|
bool scrollListener(ScrollUpdateNotification scrollNotification) {
|
||||||
if (scrollNotification.metrics.extentAfter < 100 &&
|
if (scrollNotification.metrics.extentAfter < 100 &&
|
||||||
bookmarks.loadingMore == false &&
|
bookmarks.loadingMore == false &&
|
||||||
@@ -55,99 +53,103 @@ class BookmarksScreen extends ConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: NestedScrollView(
|
body: Stack(
|
||||||
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
children: [
|
||||||
SliverOverlapAbsorber(
|
NestedScrollView(
|
||||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
||||||
sliver: SliverAppBar.large(
|
SliverOverlapAbsorber(
|
||||||
pinned: true,
|
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||||
floating: true,
|
sliver: SliverAppBar.large(
|
||||||
centerTitle: false,
|
pinned: true,
|
||||||
forceElevated: innerBoxIsScrolled,
|
floating: true,
|
||||||
title: Text(t.bookmarks.bookmarks),
|
centerTitle: false,
|
||||||
actions: [
|
forceElevated: innerBoxIsScrolled,
|
||||||
IconButton(
|
title: Text(t.bookmarks.bookmarks),
|
||||||
onPressed: () => ref.watch(routerProvider).push(RoutesPaths.bookmarksSearch),
|
actions: [
|
||||||
icon: const Icon(Icons.search_rounded),
|
IconButton(
|
||||||
tooltip: t.bookmarks.search.searchBookmarks,
|
onPressed: () => ref.watch(routerProvider).push(RoutesPaths.bookmarksSearch),
|
||||||
),
|
icon: const Icon(Icons.search_rounded),
|
||||||
const SizedBox(width: 8),
|
tooltip: t.bookmarks.search.searchBookmarks,
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
body: SafeArea(
|
|
||||||
top: false,
|
|
||||||
bottom: false,
|
|
||||||
child: Builder(
|
|
||||||
builder: (context) => RefreshIndicator(
|
|
||||||
displacement: 120,
|
|
||||||
onRefresh: () => ref.read(bookmarksProvider.notifier).refresh(),
|
|
||||||
child: NotificationListener(
|
|
||||||
onNotification: scrollListener,
|
|
||||||
child: CustomScrollView(
|
|
||||||
slivers: [
|
|
||||||
SliverOverlapInjector(
|
|
||||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
|
||||||
),
|
),
|
||||||
if (bookmarks.inialLoadStatus == LoadStatus.loading)
|
const SizedBox(width: 8),
|
||||||
const SliverFillRemaining(
|
],
|
||||||
child: Center(child: CircularProgressIndicator()),
|
),
|
||||||
),
|
),
|
||||||
if (bookmarks.inialLoadStatus == LoadStatus.error)
|
],
|
||||||
SliverFillRemaining(
|
body: SafeArea(
|
||||||
child: ErrorScreen(
|
top: false,
|
||||||
error: t.bookmarks.cannotLoadBookmarks,
|
bottom: false,
|
||||||
|
child: Builder(
|
||||||
|
builder: (context) => RefreshIndicator(
|
||||||
|
displacement: 120,
|
||||||
|
onRefresh: () => ref.read(bookmarksProvider.notifier).refresh(),
|
||||||
|
child: NotificationListener(
|
||||||
|
onNotification: scrollListener,
|
||||||
|
child: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
SliverOverlapInjector(
|
||||||
|
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||||
),
|
),
|
||||||
),
|
if (bookmarks.inialLoadStatus == LoadStatus.loading)
|
||||||
if (bookmarks.bookmarks.isEmpty)
|
const SliverFillRemaining(
|
||||||
SliverFillRemaining(
|
child: Center(child: CircularProgressIndicator()),
|
||||||
child: NoDataScreen(
|
),
|
||||||
message: t.bookmarks.noBookmarksAdded,
|
if (bookmarks.inialLoadStatus == LoadStatus.error)
|
||||||
),
|
SliverFillRemaining(
|
||||||
),
|
child: ErrorScreen(
|
||||||
if (bookmarks.bookmarks.isNotEmpty)
|
error: t.bookmarks.cannotLoadBookmarks,
|
||||||
SlidableAutoCloseBehavior(
|
),
|
||||||
child: SliverList.builder(
|
),
|
||||||
itemCount: bookmarks.bookmarks.length + 1,
|
if (bookmarks.bookmarks.isEmpty)
|
||||||
itemBuilder: (context, index) {
|
SliverFillRemaining(
|
||||||
// index == bookmarks.value!.content!.results!.length -> itemCount + 1
|
child: NoDataScreen(
|
||||||
if (index == bookmarks.bookmarks.length) {
|
message: t.bookmarks.noBookmarksAdded,
|
||||||
if (bookmarks.loadingMore) {
|
),
|
||||||
return const SizedBox(
|
),
|
||||||
height: 80,
|
if (bookmarks.bookmarks.isNotEmpty)
|
||||||
child: Center(
|
SlidableAutoCloseBehavior(
|
||||||
child: CircularProgressIndicator(),
|
child: SliverList.builder(
|
||||||
|
itemCount: bookmarks.bookmarks.length + 1,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
// index == bookmarks.value!.content!.results!.length -> itemCount + 1
|
||||||
|
if (index == bookmarks.bookmarks.length) {
|
||||||
|
if (bookmarks.loadingMore) {
|
||||||
|
return const SizedBox(
|
||||||
|
height: 80,
|
||||||
|
child: Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Bottom gap for FAB
|
||||||
|
return const SizedBox(height: 80);
|
||||||
|
}
|
||||||
|
return BookmarkItem(
|
||||||
|
bookmark: bookmarks.bookmarks[index],
|
||||||
|
onReadUnread: ref.read(bookmarksProvider.notifier).markAsReadUnread,
|
||||||
|
onDelete: (bookmark) => showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => DeleteBookmarkModal(
|
||||||
|
bookmark: bookmark,
|
||||||
|
onDelete: ref.read(bookmarksProvider.notifier).deleteBookmark,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
// Bottom gap for FAB
|
),
|
||||||
return const SizedBox(height: 80);
|
),
|
||||||
}
|
],
|
||||||
return BookmarkItem(
|
),
|
||||||
bookmark: bookmarks.bookmarks[index],
|
),
|
||||||
onReadUnread: ref.read(bookmarksProvider.notifier).markAsReadUnread,
|
|
||||||
onDelete: (bookmark) => showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => DeleteBookmarkModal(
|
|
||||||
bookmark: bookmark,
|
|
||||||
onDelete: ref.read(bookmarksProvider.notifier).deleteBookmark,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
SnackbarFloatingActionButton(
|
||||||
),
|
onPressed: openAddModal,
|
||||||
floatingActionButton: FloatingActionButton(
|
child: const Icon(Icons.add_rounded),
|
||||||
onPressed: openAddModal,
|
),
|
||||||
child: const Icon(Icons.add_rounded),
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|||||||
import 'package:linkdy/screens/onboarding/model/connect.model.dart';
|
import 'package:linkdy/screens/onboarding/model/connect.model.dart';
|
||||||
|
|
||||||
import 'package:linkdy/providers/dio_interceptor.provider.dart';
|
import 'package:linkdy/providers/dio_interceptor.provider.dart';
|
||||||
|
import 'package:linkdy/providers/snackbar.provider.dart';
|
||||||
import 'package:linkdy/providers/server_instances.provider.dart';
|
import 'package:linkdy/providers/server_instances.provider.dart';
|
||||||
import 'package:linkdy/utils/api_base_url.dart';
|
import 'package:linkdy/utils/api_base_url.dart';
|
||||||
import 'package:linkdy/i18n/strings.g.dart';
|
import 'package:linkdy/i18n/strings.g.dart';
|
||||||
import 'package:linkdy/constants/enums.dart';
|
import 'package:linkdy/constants/enums.dart';
|
||||||
import 'package:linkdy/utils/process_modal.dart';
|
import 'package:linkdy/utils/process_modal.dart';
|
||||||
import 'package:linkdy/utils/snackbar.dart';
|
|
||||||
import 'package:linkdy/models/server_instance.dart';
|
import 'package:linkdy/models/server_instance.dart';
|
||||||
import 'package:linkdy/providers/api_client.provider.dart';
|
import 'package:linkdy/providers/api_client.provider.dart';
|
||||||
import 'package:linkdy/services/api_client.dart';
|
import 'package:linkdy/services/api_client.dart';
|
||||||
@@ -116,9 +116,9 @@ FutureOr<bool> connectToServer(ConnectToServerRef ref) async {
|
|||||||
ref.read(apiClientProvider.notifier).setApiClient(apiClient);
|
ref.read(apiClientProvider.notifier).setApiClient(apiClient);
|
||||||
ref.read(serverInstancesProvider.notifier).saveNewInstance(serverInstance);
|
ref.read(serverInstancesProvider.notifier).saveNewInstance(serverInstance);
|
||||||
} else if (result == AuthResult.invalidToken) {
|
} else if (result == AuthResult.invalidToken) {
|
||||||
showSnacbkar(label: t.onboarding.invalidToken, color: Colors.red);
|
ref.read(snackbarProvider.notifier).showSnacbkar(label: t.onboarding.invalidToken, color: Colors.red);
|
||||||
} else {
|
} else {
|
||||||
showSnacbkar(label: t.onboarding.cannotConnectToServer, color: Colors.red);
|
ref.read(snackbarProvider.notifier).showSnacbkar(label: t.onboarding.cannotConnectToServer, color: Colors.red);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ part of 'connect.provider.dart';
|
|||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$connectToServerHash() => r'19a35bf2985d18662ce0b7ece8284cb4e83f1529';
|
String _$connectToServerHash() => r'370f2b67b9d20818d94e4d9b6ffb57c44aa18494';
|
||||||
|
|
||||||
/// See also [connectToServer].
|
/// See also [connectToServer].
|
||||||
@ProviderFor(connectToServer)
|
@ProviderFor(connectToServer)
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ class TagBookmarks extends _$TagBookmarks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void deleteBookmark(Bookmark bookmark) async {
|
void deleteBookmark(Bookmark bookmark) async {
|
||||||
final result = await BookmarkCommonFunctions.deleteBookmark(
|
final result = await BookmarkCommonFunctions.deleteBookmark<TagBookmarksModel>(
|
||||||
|
ref: ref,
|
||||||
bookmark: bookmark,
|
bookmark: bookmark,
|
||||||
apiClient: ref.read(apiClientProvider)!,
|
apiClient: ref.read(apiClientProvider)!,
|
||||||
);
|
);
|
||||||
@@ -109,7 +110,8 @@ class TagBookmarks extends _$TagBookmarks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void markAsReadUnread(Bookmark bookmark) async {
|
void markAsReadUnread(Bookmark bookmark) async {
|
||||||
final result = await BookmarkCommonFunctions.markAsReadUnread(
|
final result = await BookmarkCommonFunctions.markAsReadUnread<TagBookmarksModel>(
|
||||||
|
ref: ref,
|
||||||
bookmark: bookmark,
|
bookmark: bookmark,
|
||||||
apiClient: ref.read(apiClientProvider)!,
|
apiClient: ref.read(apiClientProvider)!,
|
||||||
);
|
);
|
||||||
@@ -120,7 +122,8 @@ class TagBookmarks extends _$TagBookmarks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void archiveUnarchive(Bookmark bookmark) async {
|
void archiveUnarchive(Bookmark bookmark) async {
|
||||||
final result = await BookmarkCommonFunctions.markAsReadUnread(
|
final result = await BookmarkCommonFunctions.markAsReadUnread<TagBookmarksModel>(
|
||||||
|
ref: ref,
|
||||||
bookmark: bookmark,
|
bookmark: bookmark,
|
||||||
apiClient: ref.read(apiClientProvider)!,
|
apiClient: ref.read(apiClientProvider)!,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ final tagBookmarksRequestLoadMoreProvider =
|
|||||||
);
|
);
|
||||||
|
|
||||||
typedef TagBookmarksRequestLoadMoreRef = AutoDisposeFutureProviderRef<void>;
|
typedef TagBookmarksRequestLoadMoreRef = AutoDisposeFutureProviderRef<void>;
|
||||||
String _$tagBookmarksHash() => r'452c0ac002a2c1a5b841d4233fc177a8281f9ea1';
|
String _$tagBookmarksHash() => r'ba10c98bdd9e359e885ee8edf56b99cdfcf2eb10';
|
||||||
|
|
||||||
/// See also [TagBookmarks].
|
/// See also [TagBookmarks].
|
||||||
@ProviderFor(TagBookmarks)
|
@ProviderFor(TagBookmarks)
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ 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';
|
||||||
import 'package:linkdy/utils/date_to_string.dart';
|
|
||||||
import 'package:linkdy/widgets/error_screen.dart';
|
import 'package:linkdy/widgets/error_screen.dart';
|
||||||
import 'package:linkdy/widgets/no_data_screen.dart';
|
import 'package:linkdy/widgets/no_data_screen.dart';
|
||||||
|
import 'package:linkdy/widgets/snackbar_fab.dart';
|
||||||
|
|
||||||
|
import 'package:linkdy/utils/date_to_string.dart';
|
||||||
import 'package:linkdy/i18n/strings.g.dart';
|
import 'package:linkdy/i18n/strings.g.dart';
|
||||||
|
|
||||||
class TagsScreen extends ConsumerWidget {
|
class TagsScreen extends ConsumerWidget {
|
||||||
@@ -28,113 +29,119 @@ class TagsScreen extends ConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: NestedScrollView(
|
body: Stack(
|
||||||
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
children: [
|
||||||
SliverOverlapAbsorber(
|
NestedScrollView(
|
||||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
||||||
sliver: SliverAppBar.large(
|
SliverOverlapAbsorber(
|
||||||
pinned: true,
|
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||||
floating: true,
|
sliver: SliverAppBar.large(
|
||||||
centerTitle: false,
|
pinned: true,
|
||||||
forceElevated: innerBoxIsScrolled,
|
floating: true,
|
||||||
title: Text(t.tags.tags),
|
centerTitle: false,
|
||||||
),
|
forceElevated: innerBoxIsScrolled,
|
||||||
),
|
title: Text(t.tags.tags),
|
||||||
],
|
),
|
||||||
body: SafeArea(
|
),
|
||||||
top: false,
|
],
|
||||||
bottom: false,
|
body: SafeArea(
|
||||||
child: Builder(
|
top: false,
|
||||||
builder: (context) => RefreshIndicator(
|
bottom: false,
|
||||||
displacement: 120,
|
child: Builder(
|
||||||
onRefresh: () => ref.refresh(tagsRequestProvider.future),
|
builder: (context) => RefreshIndicator(
|
||||||
child: CustomScrollView(
|
displacement: 120,
|
||||||
slivers: [
|
onRefresh: () => ref.refresh(tagsRequestProvider.future),
|
||||||
SliverOverlapInjector(
|
child: CustomScrollView(
|
||||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
slivers: [
|
||||||
),
|
SliverOverlapInjector(
|
||||||
if (tags.isLoading && !tags.isRefreshing)
|
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||||
const SliverFillRemaining(
|
|
||||||
child: Center(child: CircularProgressIndicator()),
|
|
||||||
),
|
|
||||||
if (tags.value != null && tags.value!.successful == false)
|
|
||||||
SliverFillRemaining(
|
|
||||||
child: ErrorScreen(
|
|
||||||
error: t.bookmarks.cannotLoadBookmarks,
|
|
||||||
),
|
),
|
||||||
),
|
if (tags.isLoading && !tags.isRefreshing)
|
||||||
if (tags.value != null && tags.value!.successful == true && tags.value!.content!.results!.isEmpty)
|
const SliverFillRemaining(
|
||||||
SliverFillRemaining(
|
child: Center(child: CircularProgressIndicator()),
|
||||||
child: NoDataScreen(
|
),
|
||||||
message: t.bookmarks.noBookmarksAdded,
|
if (tags.value != null && tags.value!.successful == false)
|
||||||
),
|
SliverFillRemaining(
|
||||||
),
|
child: ErrorScreen(
|
||||||
if (tags.value != null && tags.value!.successful == true && tags.value!.content!.results!.isNotEmpty)
|
error: t.bookmarks.cannotLoadBookmarks,
|
||||||
SliverList.builder(
|
|
||||||
itemCount: tags.value!.content!.results!.length + 1,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
// index == bookmarks.value!.content!.results!.length -> itemCount + 1
|
|
||||||
if (index == tags.value!.content!.results!.length) {
|
|
||||||
// Bottom gap for FAB
|
|
||||||
return const SizedBox(height: 80);
|
|
||||||
}
|
|
||||||
final tag = tags.value?.content?.results?[index];
|
|
||||||
return InkWell(
|
|
||||||
onTap: () => ref.watch(routerProvider).pushNamed(
|
|
||||||
RoutesNames.tagBookmarks,
|
|
||||||
extra: tag,
|
|
||||||
pathParameters: {'id': tag.id!.toString()},
|
|
||||||
),
|
),
|
||||||
child: Container(
|
),
|
||||||
width: double.maxFinite,
|
if (tags.value != null && tags.value!.successful == true && tags.value!.content!.results!.isEmpty)
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
SliverFillRemaining(
|
||||||
child: Column(
|
child: NoDataScreen(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
message: t.bookmarks.noBookmarksAdded,
|
||||||
children: [
|
),
|
||||||
Row(
|
),
|
||||||
|
if (tags.value != null &&
|
||||||
|
tags.value!.successful == true &&
|
||||||
|
tags.value!.content!.results!.isNotEmpty)
|
||||||
|
SliverList.builder(
|
||||||
|
itemCount: tags.value!.content!.results!.length + 1,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
// index == bookmarks.value!.content!.results!.length -> itemCount + 1
|
||||||
|
if (index == tags.value!.content!.results!.length) {
|
||||||
|
// Bottom gap for FAB
|
||||||
|
return const SizedBox(height: 80);
|
||||||
|
}
|
||||||
|
final tag = tags.value?.content?.results?[index];
|
||||||
|
return InkWell(
|
||||||
|
onTap: () => ref.watch(routerProvider).pushNamed(
|
||||||
|
RoutesNames.tagBookmarks,
|
||||||
|
extra: tag,
|
||||||
|
pathParameters: {'id': tag.id!.toString()},
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
width: double.maxFinite,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Row(
|
||||||
Icons.label_rounded,
|
children: [
|
||||||
size: 16,
|
Icon(
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.7),
|
Icons.label_rounded,
|
||||||
),
|
size: 16,
|
||||||
const SizedBox(width: 8),
|
color: Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.7),
|
||||||
Flexible(
|
|
||||||
child: Text(
|
|
||||||
tag!.name!,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
tag!.name!,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
t.tags.created(created: dateToString(tag.dateAdded!)),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
),
|
||||||
Text(
|
);
|
||||||
t.tags.created(created: dateToString(tag.dateAdded!)),
|
},
|
||||||
style: TextStyle(
|
),
|
||||||
fontSize: 14,
|
],
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
SnackbarFloatingActionButton(
|
||||||
),
|
onPressed: openAddModal,
|
||||||
floatingActionButton: FloatingActionButton(
|
child: const Icon(Icons.add_rounded),
|
||||||
onPressed: openAddModal,
|
),
|
||||||
child: const Icon(Icons.add_rounded),
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
// ignore_for_file: use_build_context_synchronously
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:linkdy/constants/global_keys.dart';
|
|
||||||
|
|
||||||
void showSnacbkar({
|
|
||||||
required String label,
|
|
||||||
required Color color,
|
|
||||||
Color? labelColor,
|
|
||||||
GlobalKey<ScaffoldMessengerState>? key,
|
|
||||||
}) async {
|
|
||||||
final GlobalKey<ScaffoldMessengerState> scaffoldKey = key ?? scaffoldMessengerGlobalKey;
|
|
||||||
|
|
||||||
final snackBar = SnackBar(
|
|
||||||
content: Text(
|
|
||||||
label,
|
|
||||||
style: TextStyle(color: labelColor ?? Colors.white),
|
|
||||||
),
|
|
||||||
backgroundColor: color,
|
|
||||||
);
|
|
||||||
scaffoldKey.currentState?.showSnackBar(snackBar);
|
|
||||||
}
|
|
||||||
29
lib/widgets/snackbar_fab.dart
Normal file
29
lib/widgets/snackbar_fab.dart
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
|
import 'package:linkdy/providers/snackbar.provider.dart';
|
||||||
|
|
||||||
|
class SnackbarFloatingActionButton extends ConsumerWidget {
|
||||||
|
final Widget child;
|
||||||
|
final void Function() onPressed;
|
||||||
|
|
||||||
|
const SnackbarFloatingActionButton({
|
||||||
|
Key? key,
|
||||||
|
required this.onPressed,
|
||||||
|
required this.child,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
return AnimatedPositioned(
|
||||||
|
bottom: ref.watch(snackbarProvider).visible == true ? 70 : 20,
|
||||||
|
right: 20,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
curve: Curves.ease,
|
||||||
|
child: FloatingActionButton(
|
||||||
|
onPressed: onPressed,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user