initial multi user feature
This commit is contained in:
+36
-23
@@ -24,7 +24,6 @@ import 'package:flutter_material_design_icons/flutter_material_design_icons.dart
|
||||
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:weblibre/core/providers/defaults.dart';
|
||||
import 'package:weblibre/core/routing/routes.dart';
|
||||
import 'package:weblibre/features/geckoview/domain/controllers/bottom_sheet.dart';
|
||||
import 'package:weblibre/features/geckoview/domain/entities/states/readerable.dart';
|
||||
@@ -45,6 +44,7 @@ import 'package:weblibre/features/geckoview/features/readerview/presentation/con
|
||||
import 'package:weblibre/features/geckoview/features/readerview/presentation/widgets/reader_button.dart';
|
||||
import 'package:weblibre/features/tor/domain/services/tor_proxy.dart';
|
||||
import 'package:weblibre/features/user/data/models/general_settings.dart';
|
||||
import 'package:weblibre/features/user/domain/providers.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/general_settings.dart';
|
||||
import 'package:weblibre/presentation/hooks/menu_controller.dart';
|
||||
import 'package:weblibre/presentation/icons/tor_icons.dart';
|
||||
@@ -236,7 +236,7 @@ class BrowserBottomAppBar extends HookConsumerWidget {
|
||||
.show(ViewTabsSheet());
|
||||
}
|
||||
} else {
|
||||
await TabViewRoute().push(context);
|
||||
await const TabViewRoute().push(context);
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
@@ -272,6 +272,19 @@ class BrowserBottomAppBar extends HookConsumerWidget {
|
||||
);
|
||||
},
|
||||
menuChildren: [
|
||||
MenuItemButton(
|
||||
onPressed: () async {
|
||||
await const SelectProfileRoute().push(context);
|
||||
},
|
||||
leadingIcon: const Icon(Icons.person),
|
||||
child: Consumer(
|
||||
builder: (context, ref, child) {
|
||||
final profile = ref.watch(selectedProfileProvider);
|
||||
return Text(profile.value?.name ?? 'Profile');
|
||||
},
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
Consumer(
|
||||
builder: (context, childRef, child) {
|
||||
final pageExtensions = childRef.watch(
|
||||
@@ -309,25 +322,25 @@ class BrowserBottomAppBar extends HookConsumerWidget {
|
||||
leadingIcon: const Icon(Icons.info),
|
||||
child: const Text('About'),
|
||||
),
|
||||
MenuItemButton(
|
||||
onPressed: () async {
|
||||
final isPrivate =
|
||||
ref
|
||||
.read(generalSettingsWithDefaultsProvider)
|
||||
.defaultCreateTabType ==
|
||||
TabType.private;
|
||||
// MenuItemButton(
|
||||
// onPressed: () async {
|
||||
// final isPrivate =
|
||||
// ref
|
||||
// .read(generalSettingsWithDefaultsProvider)
|
||||
// .defaultCreateTabType ==
|
||||
// TabType.private;
|
||||
|
||||
await ref
|
||||
.read(tabRepositoryProvider.notifier)
|
||||
.addTab(
|
||||
url: ref.read(docsUriProvider),
|
||||
private: isPrivate,
|
||||
container: const Value(null),
|
||||
);
|
||||
},
|
||||
leadingIcon: const Icon(Icons.help),
|
||||
child: const Text('Help and feedback'),
|
||||
),
|
||||
// await ref
|
||||
// .read(tabRepositoryProvider.notifier)
|
||||
// .addTab(
|
||||
// url: ref.read(docsUriProvider),
|
||||
// private: isPrivate,
|
||||
// container: const Value(null),
|
||||
// );
|
||||
// },
|
||||
// leadingIcon: const Icon(Icons.help),
|
||||
// child: const Text('Help and feedback'),
|
||||
// ),
|
||||
const Divider(),
|
||||
MenuItemButton(
|
||||
onPressed: () async {
|
||||
@@ -338,7 +351,7 @@ class BrowserBottomAppBar extends HookConsumerWidget {
|
||||
),
|
||||
MenuItemButton(
|
||||
onPressed: () async {
|
||||
await HistoryRoute().push(context);
|
||||
await const HistoryRoute().push(context);
|
||||
},
|
||||
leadingIcon: const Icon(Icons.history),
|
||||
child: const Text('History'),
|
||||
@@ -403,7 +416,7 @@ class BrowserBottomAppBar extends HookConsumerWidget {
|
||||
),
|
||||
MenuItemButton(
|
||||
onPressed: () async {
|
||||
await TorProxyRoute().push(context);
|
||||
await const TorProxyRoute().push(context);
|
||||
},
|
||||
leadingIcon: const Icon(TorIcons.onionAlt),
|
||||
child: Consumer(
|
||||
@@ -433,7 +446,7 @@ class BrowserBottomAppBar extends HookConsumerWidget {
|
||||
),
|
||||
MenuItemButton(
|
||||
onPressed: () async {
|
||||
await ContainerListRoute().push(context);
|
||||
await const ContainerListRoute().push(context);
|
||||
},
|
||||
leadingIcon: const Icon(MdiIcons.folder),
|
||||
child: const Text('Containers'),
|
||||
|
||||
@@ -26,8 +26,8 @@ part 'readerable.g.dart';
|
||||
GeckoReaderableService readerableService(Ref ref) {
|
||||
final service = GeckoReaderableService.setUp();
|
||||
|
||||
ref.onDispose(() {
|
||||
service.dispose();
|
||||
ref.onDispose(() async {
|
||||
await service.dispose();
|
||||
});
|
||||
|
||||
return service;
|
||||
|
||||
@@ -54,7 +54,7 @@ final class ReaderableServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$readerableServiceHash() => r'03182c8afc41f5184322a3206473cbfa96df5819';
|
||||
String _$readerableServiceHash() => r'0c432ede496d85ed6a7d028af346b129d97f7502';
|
||||
|
||||
@ProviderFor(appearanceButtonVisibility)
|
||||
const appearanceButtonVisibilityProvider =
|
||||
|
||||
@@ -17,14 +17,15 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart' as path_provider;
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:sqlite3/sqlite3.dart';
|
||||
import 'package:sqlite3_flutter_libs/sqlite3_flutter_libs.dart';
|
||||
import 'package:universal_io/io.dart';
|
||||
|
||||
import 'package:weblibre/core/filesystem.dart';
|
||||
import 'package:weblibre/data/database/functions/lexo_rank_functions.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/data/database/database.dart';
|
||||
|
||||
@@ -34,23 +35,13 @@ part 'providers.g.dart';
|
||||
TabDatabase tabDatabase(Ref ref) {
|
||||
final db = TabDatabase(
|
||||
LazyDatabase(() async {
|
||||
// put the database file, called db.sqlite here, into the documents folder
|
||||
// for your app.
|
||||
final dbFolder = await path_provider.getApplicationDocumentsDirectory();
|
||||
final file = File(p.join(dbFolder.path, 'tab2.db'));
|
||||
final file = File(p.join(filesystem.profileDatabasesDir.path, 'tab.db'));
|
||||
|
||||
// Also work around limitations on old Android versions
|
||||
if (Platform.isAndroid) {
|
||||
await applyWorkaroundToOpenSqlite3OnOldAndroidVersions();
|
||||
}
|
||||
|
||||
// Make sqlite3 pick a more suitable location for temporary files - the
|
||||
// one from the system may be inaccessible due to sandboxing.
|
||||
final cachebase = (await path_provider.getTemporaryDirectory()).path;
|
||||
// We can't access /tmp on Android, which sqlite3 would try by default.
|
||||
// Explicitly tell it about the correct temporary directory.
|
||||
sqlite3.tempDirectory = cachebase;
|
||||
|
||||
return NativeDatabase.createInBackground(
|
||||
file,
|
||||
setup: (database) {
|
||||
|
||||
@@ -48,4 +48,4 @@ final class TabDatabaseProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$tabDatabaseHash() => r'422bd4789296dc271fabbd5906f2e2ab16bccaa3';
|
||||
String _$tabDatabaseHash() => r'337dbcf30bd57dcee409aec0aa93f1f6f2783368';
|
||||
|
||||
Reference in New Issue
Block a user