Improved tablet webview
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'package:linkdy/screens/webview/ui/webview.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/common_functions.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/favicon_loader.provider.dart';
|
||||
import 'package:linkdy/screens/bookmarks/model/bookmarks.model.dart';
|
||||
@@ -59,12 +62,29 @@ FutureOr<void> bookmarksRequestLoadMore(BookmarksRequestLoadMoreRef ref) async {
|
||||
ref.read(bookmarksProvider.notifier).setLoadingMore(false);
|
||||
}
|
||||
|
||||
const _webViewRoute = "wb";
|
||||
const _webViewRoutePath = "/wb";
|
||||
|
||||
@riverpod
|
||||
class Bookmarks extends _$Bookmarks {
|
||||
@override
|
||||
BookmarksModel build() {
|
||||
final model = BookmarksModel(
|
||||
bookmarks: [],
|
||||
webViewRouter: GoRouter(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: "/",
|
||||
builder: (context, state) => const SizedBox(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: _webViewRoute,
|
||||
builder: (context, state) => WebViewScreen(bookmark: state.extra as Bookmark),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
ref.read(bookmarksRequestProvider(model.readStatus, model.limit));
|
||||
return model;
|
||||
@@ -98,11 +118,27 @@ class Bookmarks extends _$Bookmarks {
|
||||
ref.notifyListeners();
|
||||
}
|
||||
|
||||
void pushRoute(String path, bool splitMode) {
|
||||
if (splitMode == true && state.webViewRouter.canPop()) {
|
||||
state.selectedBookmark = null;
|
||||
ref.notifyListeners();
|
||||
state.webViewRouter.pop();
|
||||
}
|
||||
ref.read(routerProvider).push(path);
|
||||
}
|
||||
|
||||
void clearSelectedBookmark() {
|
||||
state.selectedBookmark = null;
|
||||
ref.notifyListeners();
|
||||
}
|
||||
|
||||
void selectBookmark(Bookmark bookmark, double width) {
|
||||
if (width <= Sizes.tabletBreakpoint && ref.watch(appStatusProvider).useInAppBrowser == true) {
|
||||
ref.watch(routerProvider).push(RoutesPaths.webview, extra: bookmark);
|
||||
} else if (width <= Sizes.tabletBreakpoint && ref.watch(appStatusProvider).useInAppBrowser == false) {
|
||||
openUrl(bookmark.url!);
|
||||
} else if (bookmark != state.selectedBookmark) {
|
||||
state.webViewRouter.go(_webViewRoutePath, extra: bookmark);
|
||||
}
|
||||
state.selectedBookmark = bookmark;
|
||||
ref.notifyListeners();
|
||||
|
||||
@@ -189,7 +189,7 @@ final bookmarksRequestLoadMoreProvider =
|
||||
);
|
||||
|
||||
typedef BookmarksRequestLoadMoreRef = AutoDisposeFutureProviderRef<void>;
|
||||
String _$bookmarksHash() => r'80e94e586950b9072f229958f98c88069086d7ab';
|
||||
String _$bookmarksHash() => r'84c91bf9112343e4680040bfe25b5e17fb2f92d2';
|
||||
|
||||
/// See also [Bookmarks].
|
||||
@ProviderFor(Bookmarks)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'package:linkdy/screens/webview/ui/webview.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/favicon_loader.provider.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/bookmarks.provider.dart';
|
||||
import 'package:linkdy/screens/bookmarks/provider/common_functions.dart';
|
||||
@@ -63,6 +65,9 @@ FutureOr<void> fetchSearchBookmarksLoadMore(FetchSearchBookmarksLoadMoreRef ref)
|
||||
ref.read(searchBookmarksProvider.notifier).setLoadingMore(false);
|
||||
}
|
||||
|
||||
const _webViewRoute = "wb";
|
||||
const _webViewRoutePath = "/wb";
|
||||
|
||||
@riverpod
|
||||
class SearchBookmarks extends _$SearchBookmarks {
|
||||
@override
|
||||
@@ -70,6 +75,20 @@ class SearchBookmarks extends _$SearchBookmarks {
|
||||
final model = SearchBookmarksModel(
|
||||
searchController: TextEditingController(),
|
||||
bookmarks: [],
|
||||
webViewRouter: GoRouter(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: "/",
|
||||
builder: (context, state) => const SizedBox(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: _webViewRoute,
|
||||
builder: (context, state) => WebViewScreen(bookmark: state.extra as Bookmark),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
ref.read(fetchSearchBookmarksProvider(model.limit));
|
||||
return model;
|
||||
@@ -109,6 +128,8 @@ class SearchBookmarks extends _$SearchBookmarks {
|
||||
ref.watch(routerProvider).push(RoutesPaths.webview, extra: bookmark);
|
||||
} else if (width <= Sizes.tabletBreakpoint && ref.watch(appStatusProvider).useInAppBrowser == false) {
|
||||
openUrl(bookmark.url!);
|
||||
} else if (bookmark != state.selectedBookmark) {
|
||||
state.webViewRouter.go(_webViewRoutePath, extra: bookmark);
|
||||
}
|
||||
state.selectedBookmark = bookmark;
|
||||
ref.notifyListeners();
|
||||
|
||||
@@ -174,7 +174,7 @@ final fetchSearchBookmarksLoadMoreProvider =
|
||||
);
|
||||
|
||||
typedef FetchSearchBookmarksLoadMoreRef = AutoDisposeFutureProviderRef<void>;
|
||||
String _$searchBookmarksHash() => r'3daf460b8389e8bcf8498c4bdf3935e88f4ce156';
|
||||
String _$searchBookmarksHash() => r'5ebbd8dbfe705cbca9552fc60d251372c771d738';
|
||||
|
||||
/// See also [SearchBookmarks].
|
||||
@ProviderFor(SearchBookmarks)
|
||||
|
||||
Reference in New Issue
Block a user