对接用户协议和隐私政策
This commit is contained in:
33
lib/components/legal_document.dart
Normal file
33
lib/components/legal_document.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../core/localization/app_localizations.dart';
|
||||
import 'capsule_toast.dart';
|
||||
|
||||
enum LegalDocument {
|
||||
privacy('my.privacy_policy', 'https://ri.satabot.com/web/legal/privacy.html'),
|
||||
terms('my.user_agreement', 'https://ri.satabot.com/web/legal/terms.html');
|
||||
|
||||
const LegalDocument(this.titleKey, this.url);
|
||||
|
||||
final String titleKey;
|
||||
final String url;
|
||||
}
|
||||
|
||||
Future<void> openLegalDocument(
|
||||
BuildContext context,
|
||||
LegalDocument document,
|
||||
) async {
|
||||
final errorText = AppLocalizations.of(context).translate('legal.open_failed');
|
||||
try {
|
||||
final opened = await launchUrl(
|
||||
Uri.parse(document.url),
|
||||
mode: LaunchMode.inAppBrowserView,
|
||||
webOnlyWindowName: '_blank',
|
||||
);
|
||||
if (opened) return;
|
||||
} catch (_) {
|
||||
// 平台无法打开时保留当前页面,并向用户提供重试提示。
|
||||
}
|
||||
if (context.mounted) CapsuleToast.show(errorText, showCheck: false);
|
||||
}
|
||||
Reference in New Issue
Block a user