Add subscription qr code share
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:hiddify/core/router/router.dart';
|
||||
import 'package:hiddify/domain/failures.dart';
|
||||
import 'package:hiddify/domain/profiles/profiles.dart';
|
||||
import 'package:hiddify/features/common/confirmation_dialogs.dart';
|
||||
import 'package:hiddify/features/common/qr_code_dialog.dart';
|
||||
import 'package:hiddify/features/profiles/notifier/notifier.dart';
|
||||
import 'package:hiddify/utils/utils.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
@@ -289,7 +290,7 @@ class ProfileActionsMenu extends HookConsumerWidget {
|
||||
),
|
||||
SubmenuButton(
|
||||
menuChildren: [
|
||||
if (profile case RemoteProfile(:final url, :final name))
|
||||
if (profile case RemoteProfile(:final url, :final name)) ...[
|
||||
MenuItemButton(
|
||||
child: Text(t.profile.share.exportSubLinkToClipboard),
|
||||
onPressed: () async {
|
||||
@@ -303,6 +304,19 @@ class ProfileActionsMenu extends HookConsumerWidget {
|
||||
}
|
||||
},
|
||||
),
|
||||
MenuItemButton(
|
||||
child: Text(t.profile.share.subLinkQrCode),
|
||||
onPressed: () async {
|
||||
final link = LinkParser.generateSubShareLink(url, name);
|
||||
if (link.isNotEmpty) {
|
||||
await QrCodeDialog(
|
||||
link,
|
||||
message: name,
|
||||
).show(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
MenuItemButton(
|
||||
child: Text(t.profile.share.exportConfigToClipboard),
|
||||
onPressed: () async {
|
||||
|
||||
61
lib/features/common/qr_code_dialog.dart
Normal file
61
lib/features/common/qr_code_dialog.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
|
||||
class QrCodeDialog extends StatelessWidget {
|
||||
const QrCodeDialog(
|
||||
this.data, {
|
||||
super.key,
|
||||
this.message,
|
||||
this.width = 268,
|
||||
this.backgroundColor = Colors.white,
|
||||
});
|
||||
|
||||
final String data;
|
||||
final String? message;
|
||||
final double width;
|
||||
final Color backgroundColor;
|
||||
|
||||
Future<void> show(BuildContext context) async {
|
||||
await showDialog(context: context, builder: (context) => this);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: width,
|
||||
child: QrImageView(
|
||||
data: data,
|
||||
backgroundColor: backgroundColor,
|
||||
),
|
||||
),
|
||||
if (message != null)
|
||||
SizedBox(
|
||||
width: width,
|
||||
child: Material(
|
||||
color: theme.colorScheme.background,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
message!,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: theme.colorScheme.onBackground),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user