Rise fabs when snackbar is shown
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/// Locales: 2
|
||||
/// 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
|
||||
// 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/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';
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.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/providers/server_instances.provider.dart';
|
||||
import 'package:linkdy/router/routes.dart';
|
||||
import 'package:linkdy/utils/snackbar.dart';
|
||||
import 'package:linkdy/router/paths.dart';
|
||||
import 'package:linkdy/providers/api_client.provider.dart';
|
||||
|
||||
@@ -23,7 +23,7 @@ InterceptorsWrapper dioInterceptor(DioInterceptorRef ref) {
|
||||
GoRouter.of(rootNavigatorKey.currentContext!).pushReplacement(RoutesPaths.onboarding);
|
||||
ref.read(apiClientProvider.notifier).disconnectApiClient();
|
||||
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);
|
||||
},
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'dio_interceptor.provider.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$dioInterceptorHash() => r'449d19df5bf143a7e0f92249d99b4d223b2468f3';
|
||||
String _$dioInterceptorHash() => r'15186eb74bde12048a96b1d38f1c9308c9f435a8';
|
||||
|
||||
/// See also [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/model/add_link.model.dart';
|
||||
|
||||
import 'package:linkdy/providers/snackbar.provider.dart';
|
||||
import 'package:linkdy/models/data/tags.dart';
|
||||
import 'package:linkdy/utils/snackbar.dart';
|
||||
import 'package:linkdy/i18n/strings.g.dart';
|
||||
import 'package:linkdy/utils/process_modal.dart';
|
||||
import 'package:linkdy/models/data/set_bookmark_data.dart';
|
||||
@@ -101,7 +101,7 @@ class AddBookmark extends _$AddBookmark {
|
||||
ref.read(bookmarksProvider.notifier).refresh();
|
||||
ref.watch(routerProvider).pop();
|
||||
} else {
|
||||
showSnacbkar(
|
||||
ref.read(snackbarProvider.notifier).showSnacbkar(
|
||||
label: t.bookmarks.addBookmark.errorSavingBookmark,
|
||||
color: Colors.red,
|
||||
);
|
||||
|
||||
@@ -175,7 +175,7 @@ final getTagsProvider =
|
||||
);
|
||||
|
||||
typedef GetTagsRef = AutoDisposeFutureProviderRef<ApiResponse<TagsResponse>>;
|
||||
String _$addBookmarkHash() => r'510fe4dbdc6628a13be9d8c5c2581fd5ac94ca68';
|
||||
String _$addBookmarkHash() => r'd6425004c3e755ec539ad28da3ef44349680b04b';
|
||||
|
||||
/// See also [AddBookmark].
|
||||
@ProviderFor(AddBookmark)
|
||||
|
||||
@@ -89,7 +89,8 @@ class Bookmarks extends _$Bookmarks {
|
||||
}
|
||||
|
||||
void deleteBookmark(Bookmark bookmark) async {
|
||||
final result = await BookmarkCommonFunctions.deleteBookmark(
|
||||
final result = await BookmarkCommonFunctions.deleteBookmark<BookmarksModel>(
|
||||
ref: ref,
|
||||
bookmark: bookmark,
|
||||
apiClient: ref.read(apiClientProvider)!,
|
||||
);
|
||||
@@ -100,7 +101,8 @@ class Bookmarks extends _$Bookmarks {
|
||||
}
|
||||
|
||||
void markAsReadUnread(Bookmark bookmark) async {
|
||||
final result = await BookmarkCommonFunctions.markAsReadUnread(
|
||||
final result = await BookmarkCommonFunctions.markAsReadUnread<BookmarksModel>(
|
||||
ref: ref,
|
||||
bookmark: bookmark,
|
||||
apiClient: ref.read(apiClientProvider)!,
|
||||
);
|
||||
@@ -111,7 +113,8 @@ class Bookmarks extends _$Bookmarks {
|
||||
}
|
||||
|
||||
void archiveUnarchive(Bookmark bookmark) async {
|
||||
final result = await BookmarkCommonFunctions.markAsReadUnread(
|
||||
final result = await BookmarkCommonFunctions.archiveUnarchive<BookmarksModel>(
|
||||
ref: ref,
|
||||
bookmark: bookmark,
|
||||
apiClient: ref.read(apiClientProvider)!,
|
||||
);
|
||||
|
||||
@@ -172,7 +172,7 @@ final bookmarksRequestLoadMoreProvider =
|
||||
);
|
||||
|
||||
typedef BookmarksRequestLoadMoreRef = AutoDisposeFutureProviderRef<void>;
|
||||
String _$bookmarksHash() => r'82c31fa1cbab1ba1e5c77486e7dc7ce5a86e20a5';
|
||||
String _$bookmarksHash() => r'71282b9487a2e9d4a17973af7fb3da7c0171f8d0';
|
||||
|
||||
/// See also [Bookmarks].
|
||||
@ProviderFor(Bookmarks)
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
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/models/data/bookmarks.dart';
|
||||
import 'package:linkdy/models/data/set_bookmark_data.dart';
|
||||
import 'package:linkdy/services/api_client.dart';
|
||||
import 'package:linkdy/utils/process_modal.dart';
|
||||
import 'package:linkdy/utils/snackbar.dart';
|
||||
|
||||
class BookmarkCommonFunctions {
|
||||
static Future<bool> deleteBookmark({
|
||||
static Future<bool> deleteBookmark<T>({
|
||||
required AutoDisposeNotifierProviderRef<T> ref,
|
||||
required Bookmark bookmark,
|
||||
required ApiClientService apiClient,
|
||||
}) async {
|
||||
@@ -19,14 +21,19 @@ class BookmarkCommonFunctions {
|
||||
|
||||
processModal.close();
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
|
||||
static Future<Bookmark?> markAsReadUnread({
|
||||
static Future<Bookmark?> markAsReadUnread<T>({
|
||||
required AutoDisposeNotifierProviderRef<T> ref,
|
||||
required Bookmark bookmark,
|
||||
required ApiClientService apiClient,
|
||||
}) async {
|
||||
@@ -50,7 +57,7 @@ class BookmarkCommonFunctions {
|
||||
|
||||
processModal.close();
|
||||
if (result.successful == true) {
|
||||
showSnacbkar(
|
||||
ref.read(snackbarProvider.notifier).showSnacbkar(
|
||||
label: bookmark.unread == true
|
||||
? t.bookmarks.bookmarkOptions.markedAsReadSuccessfully
|
||||
: t.bookmarks.bookmarkOptions.markedAsUnreadSuccessfully,
|
||||
@@ -58,7 +65,7 @@ class BookmarkCommonFunctions {
|
||||
);
|
||||
return result.content;
|
||||
} else {
|
||||
showSnacbkar(
|
||||
ref.read(snackbarProvider.notifier).showSnacbkar(
|
||||
label: bookmark.unread == true
|
||||
? t.bookmarks.bookmarkOptions.bookmarkNotMarkedAsRead
|
||||
: t.bookmarks.bookmarkOptions.bookmarkNotMarkedAsUnread,
|
||||
@@ -68,7 +75,8 @@ class BookmarkCommonFunctions {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Bookmark?> archiveUnarchive({
|
||||
static Future<Bookmark?> archiveUnarchive<T>({
|
||||
required AutoDisposeNotifierProviderRef<T> ref,
|
||||
required Bookmark bookmark,
|
||||
required ApiClientService apiClient,
|
||||
}) async {
|
||||
@@ -94,7 +102,7 @@ class BookmarkCommonFunctions {
|
||||
|
||||
processModal.close();
|
||||
if (result.successful == true) {
|
||||
showSnacbkar(
|
||||
ref.read(snackbarProvider.notifier).showSnacbkar(
|
||||
label: bookmark.isArchived == true
|
||||
? t.bookmarks.bookmarkOptions.bookmarkUnrchivedSuccessfully
|
||||
: t.bookmarks.bookmarkOptions.bookmarkArchivedSuccessfully,
|
||||
@@ -102,7 +110,7 @@ class BookmarkCommonFunctions {
|
||||
);
|
||||
return result.content;
|
||||
} else {
|
||||
showSnacbkar(
|
||||
ref.read(snackbarProvider.notifier).showSnacbkar(
|
||||
label: bookmark.isArchived == true
|
||||
? t.bookmarks.bookmarkOptions.bookmarkNotUnrchived
|
||||
: t.bookmarks.bookmarkOptions.bookmarkNotArchived,
|
||||
|
||||
@@ -99,7 +99,8 @@ class SearchBookmarks extends _$SearchBookmarks {
|
||||
}
|
||||
|
||||
void deleteBookmark(Bookmark bookmark) async {
|
||||
final result = await BookmarkCommonFunctions.deleteBookmark(
|
||||
final result = await BookmarkCommonFunctions.deleteBookmark<SearchBookmarksModel>(
|
||||
ref: ref,
|
||||
bookmark: bookmark,
|
||||
apiClient: ref.read(apiClientProvider)!,
|
||||
);
|
||||
@@ -113,7 +114,8 @@ class SearchBookmarks extends _$SearchBookmarks {
|
||||
}
|
||||
|
||||
void markAsReadUnread(Bookmark bookmark) async {
|
||||
final result = await BookmarkCommonFunctions.markAsReadUnread(
|
||||
final result = await BookmarkCommonFunctions.markAsReadUnread<SearchBookmarksModel>(
|
||||
ref: ref,
|
||||
bookmark: bookmark,
|
||||
apiClient: ref.read(apiClientProvider)!,
|
||||
);
|
||||
@@ -127,7 +129,8 @@ class SearchBookmarks extends _$SearchBookmarks {
|
||||
}
|
||||
|
||||
void archiveUnarchive(Bookmark bookmark) async {
|
||||
final result = await BookmarkCommonFunctions.markAsReadUnread(
|
||||
final result = await BookmarkCommonFunctions.markAsReadUnread<SearchBookmarksModel>(
|
||||
ref: ref,
|
||||
bookmark: bookmark,
|
||||
apiClient: ref.read(apiClientProvider)!,
|
||||
);
|
||||
|
||||
@@ -174,7 +174,7 @@ final fetchSearchBookmarksLoadMoreProvider =
|
||||
);
|
||||
|
||||
typedef FetchSearchBookmarksLoadMoreRef = AutoDisposeFutureProviderRef<void>;
|
||||
String _$searchBookmarksHash() => r'843fe597bceab3e3f512b5b4a40ddd1dbeb09f9d';
|
||||
String _$searchBookmarksHash() => r'6e8eea2bf9c19b33f626e64ae74210d9b374065f';
|
||||
|
||||
/// See also [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/widgets/error_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/providers/router.provider.dart';
|
||||
import 'package:linkdy/models/data/bookmarks.dart';
|
||||
import 'package:linkdy/router/paths.dart';
|
||||
|
||||
class BookmarksScreen extends ConsumerWidget {
|
||||
@@ -42,8 +42,6 @@ class BookmarksScreen extends ConsumerWidget {
|
||||
);
|
||||
}
|
||||
|
||||
void openDeleteBookmarkModal(Bookmark bookmark) {}
|
||||
|
||||
bool scrollListener(ScrollUpdateNotification scrollNotification) {
|
||||
if (scrollNotification.metrics.extentAfter < 100 &&
|
||||
bookmarks.loadingMore == false &&
|
||||
@@ -55,7 +53,9 @@ class BookmarksScreen extends ConsumerWidget {
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
body: NestedScrollView(
|
||||
body: Stack(
|
||||
children: [
|
||||
NestedScrollView(
|
||||
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
||||
SliverOverlapAbsorber(
|
||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||
@@ -145,10 +145,12 @@ class BookmarksScreen extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
SnackbarFloatingActionButton(
|
||||
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/providers/dio_interceptor.provider.dart';
|
||||
import 'package:linkdy/providers/snackbar.provider.dart';
|
||||
import 'package:linkdy/providers/server_instances.provider.dart';
|
||||
import 'package:linkdy/utils/api_base_url.dart';
|
||||
import 'package:linkdy/i18n/strings.g.dart';
|
||||
import 'package:linkdy/constants/enums.dart';
|
||||
import 'package:linkdy/utils/process_modal.dart';
|
||||
import 'package:linkdy/utils/snackbar.dart';
|
||||
import 'package:linkdy/models/server_instance.dart';
|
||||
import 'package:linkdy/providers/api_client.provider.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(serverInstancesProvider.notifier).saveNewInstance(serverInstance);
|
||||
} 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 {
|
||||
showSnacbkar(label: t.onboarding.cannotConnectToServer, color: Colors.red);
|
||||
ref.read(snackbarProvider.notifier).showSnacbkar(label: t.onboarding.cannotConnectToServer, color: Colors.red);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'connect.provider.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$connectToServerHash() => r'19a35bf2985d18662ce0b7ece8284cb4e83f1529';
|
||||
String _$connectToServerHash() => r'370f2b67b9d20818d94e4d9b6ffb57c44aa18494';
|
||||
|
||||
/// See also [connectToServer].
|
||||
@ProviderFor(connectToServer)
|
||||
|
||||
@@ -98,7 +98,8 @@ class TagBookmarks extends _$TagBookmarks {
|
||||
}
|
||||
|
||||
void deleteBookmark(Bookmark bookmark) async {
|
||||
final result = await BookmarkCommonFunctions.deleteBookmark(
|
||||
final result = await BookmarkCommonFunctions.deleteBookmark<TagBookmarksModel>(
|
||||
ref: ref,
|
||||
bookmark: bookmark,
|
||||
apiClient: ref.read(apiClientProvider)!,
|
||||
);
|
||||
@@ -109,7 +110,8 @@ class TagBookmarks extends _$TagBookmarks {
|
||||
}
|
||||
|
||||
void markAsReadUnread(Bookmark bookmark) async {
|
||||
final result = await BookmarkCommonFunctions.markAsReadUnread(
|
||||
final result = await BookmarkCommonFunctions.markAsReadUnread<TagBookmarksModel>(
|
||||
ref: ref,
|
||||
bookmark: bookmark,
|
||||
apiClient: ref.read(apiClientProvider)!,
|
||||
);
|
||||
@@ -120,7 +122,8 @@ class TagBookmarks extends _$TagBookmarks {
|
||||
}
|
||||
|
||||
void archiveUnarchive(Bookmark bookmark) async {
|
||||
final result = await BookmarkCommonFunctions.markAsReadUnread(
|
||||
final result = await BookmarkCommonFunctions.markAsReadUnread<TagBookmarksModel>(
|
||||
ref: ref,
|
||||
bookmark: bookmark,
|
||||
apiClient: ref.read(apiClientProvider)!,
|
||||
);
|
||||
|
||||
@@ -206,7 +206,7 @@ final tagBookmarksRequestLoadMoreProvider =
|
||||
);
|
||||
|
||||
typedef TagBookmarksRequestLoadMoreRef = AutoDisposeFutureProviderRef<void>;
|
||||
String _$tagBookmarksHash() => r'452c0ac002a2c1a5b841d4233fc177a8281f9ea1';
|
||||
String _$tagBookmarksHash() => r'ba10c98bdd9e359e885ee8edf56b99cdfcf2eb10';
|
||||
|
||||
/// See also [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/ui/add_tag_modal.dart';
|
||||
import 'package:linkdy/utils/date_to_string.dart';
|
||||
import 'package:linkdy/widgets/error_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';
|
||||
|
||||
class TagsScreen extends ConsumerWidget {
|
||||
@@ -28,7 +29,9 @@ class TagsScreen extends ConsumerWidget {
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
body: NestedScrollView(
|
||||
body: Stack(
|
||||
children: [
|
||||
NestedScrollView(
|
||||
headerSliverBuilder: (context, innerBoxIsScrolled) => [
|
||||
SliverOverlapAbsorber(
|
||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||
@@ -69,7 +72,9 @@ class TagsScreen extends ConsumerWidget {
|
||||
message: t.bookmarks.noBookmarksAdded,
|
||||
),
|
||||
),
|
||||
if (tags.value != null && tags.value!.successful == true && tags.value!.content!.results!.isNotEmpty)
|
||||
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) {
|
||||
@@ -132,10 +137,12 @@ class TagsScreen extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
SnackbarFloatingActionButton(
|
||||
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