move open url into bottom sheet
This commit is contained in:
@@ -211,7 +211,7 @@ class OpenSharedContentRoute extends GoRouteData with $OpenSharedContentRoute {
|
||||
|
||||
@override
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
return DialogPage(
|
||||
return BottomSheetPage(
|
||||
builder: (_) => OpenSharedContent(
|
||||
sharedUrl: Uri.tryParse(sharedUrl) ?? Uri.parse('about:blank'),
|
||||
),
|
||||
|
||||
+98
-40
@@ -17,16 +17,18 @@
|
||||
* 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 'package:drift/drift.dart';
|
||||
import 'package:drift/drift.dart' hide Column;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:flutter_material_design_icons/flutter_material_design_icons.dart';
|
||||
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart'
|
||||
show GeckoBrowserService;
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:weblibre/core/design/app_colors.dart';
|
||||
import 'package:weblibre/features/geckoview/domain/repositories/tab.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/data/models/container_data.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/presentation/widgets/container_chips.dart';
|
||||
import 'package:weblibre/presentation/icons/weblibre_icons.dart';
|
||||
import 'package:weblibre/utils/form_validators.dart';
|
||||
|
||||
class OpenSharedContent extends HookConsumerWidget {
|
||||
@@ -38,6 +40,7 @@ class OpenSharedContent extends HookConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final formKey = useMemoized(() => GlobalKey<FormState>());
|
||||
final textController = useTextEditingController(text: sharedUrl.toString());
|
||||
final appColors = AppColors.of(context);
|
||||
|
||||
final selectedContainer = useState<ContainerData?>(null);
|
||||
|
||||
@@ -59,16 +62,32 @@ class OpenSharedContent extends HookConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
return Form(
|
||||
key: formKey,
|
||||
child: SimpleDialog(
|
||||
title: const Text('Open URL'),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.symmetric(horizontal: 16.0),
|
||||
child: SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: ContainerChips(
|
||||
Future<void> openCustomTab(bool isPrivate) async {
|
||||
if (formKey.currentState?.validate() == true) {
|
||||
await GeckoBrowserService().openInCustomTab(
|
||||
url: Uri.parse(textController.text),
|
||||
private: isPrivate,
|
||||
contextId: selectedContainer.value?.id,
|
||||
);
|
||||
|
||||
if (context.mounted) {
|
||||
context.pop(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SafeArea(
|
||||
child: Form(
|
||||
key: formKey,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text('Open link', style: Theme.of(context).textTheme.titleLarge),
|
||||
const SizedBox(height: 16),
|
||||
ContainerChips(
|
||||
displayMenu: false,
|
||||
selectedContainer: selectedContainer.value,
|
||||
onSelected: (container) {
|
||||
@@ -78,36 +97,75 @@ class OpenSharedContent extends HookConsumerWidget {
|
||||
selectedContainer.value = null;
|
||||
},
|
||||
),
|
||||
),
|
||||
TextFormField(
|
||||
controller: textController,
|
||||
keyboardType: TextInputType.url,
|
||||
minLines: 1,
|
||||
maxLines: 10,
|
||||
validator: (value) {
|
||||
return validateUrl(value, eagerParsing: false);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_OpenActionTile(
|
||||
title: 'Open in new tab',
|
||||
subtitle: 'Add to your browser tabs',
|
||||
icon: MdiIcons.tab,
|
||||
privateColor: appColors.privateTabPurple,
|
||||
onTap: () => openTab(false),
|
||||
onPrivateTap: () => openTab(true),
|
||||
),
|
||||
_OpenActionTile(
|
||||
title: 'Open in custom tab',
|
||||
subtitle: 'Open in a separate window',
|
||||
icon: MdiIcons.applicationOutline,
|
||||
privateColor: appColors.privateTabPurple,
|
||||
onTap: () => openCustomTab(false),
|
||||
onPrivateTap: () => openCustomTab(true),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.symmetric(horizontal: 16.0),
|
||||
child: TextFormField(
|
||||
controller: textController,
|
||||
keyboardType: TextInputType.url,
|
||||
minLines: 1,
|
||||
maxLines: 10,
|
||||
validator: (value) {
|
||||
return validateUrl(value, eagerParsing: false);
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Open Regular Tab'),
|
||||
leading: const Icon(MdiIcons.tab),
|
||||
onTap: () async {
|
||||
await openTab(false);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Open Private Tab'),
|
||||
leading: const Icon(WebLibreIcons.privateTab),
|
||||
onTap: () async {
|
||||
await openTab(true);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _OpenActionTile extends StatelessWidget {
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final IconData icon;
|
||||
final Color privateColor;
|
||||
final VoidCallback onTap;
|
||||
final VoidCallback onPrivateTap;
|
||||
|
||||
const _OpenActionTile({
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
required this.icon,
|
||||
required this.privateColor,
|
||||
required this.onTap,
|
||||
required this.onPrivateTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
title: Text(title),
|
||||
subtitle: subtitle != null ? Text(subtitle!) : null,
|
||||
leading: Icon(icon),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(height: 24, child: VerticalDivider(width: 16)),
|
||||
IconButton(
|
||||
icon: Icon(MdiIcons.dominoMask, color: privateColor, size: 24),
|
||||
tooltip: 'Private',
|
||||
onPressed: onPrivateTap,
|
||||
),
|
||||
],
|
||||
),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ final class UserBackupServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$userBackupServiceHash() => r'a0bcf458e6b0a982f1fc90fce99e60cc3418f4d9';
|
||||
String _$userBackupServiceHash() => r'fb0b29075da3b32135d6309ef1bb7a7f119a3e25';
|
||||
|
||||
abstract class _$UserBackupService extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
Reference in New Issue
Block a user