136 lines
4.9 KiB
Dart
136 lines
4.9 KiB
Dart
import 'package:ef/ef.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter_pdfview/flutter_pdfview.dart';
|
||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||
import 'package:vbvs_app/controller/setting/pdf/PrivacyPdfController.dart';
|
||
import 'package:flutter/services.dart';
|
||
|
||
class PrivacyPolicyPage extends StatefulWidget {
|
||
PrivacyPolicyPage({super.key});
|
||
|
||
@override
|
||
State<PrivacyPolicyPage> createState() => _PrivacyPolicyPageState();
|
||
}
|
||
|
||
class _PrivacyPolicyPageState extends State<PrivacyPolicyPage> {
|
||
PrivacyPdfController pdfController = Get.find();
|
||
// MHLanguageController languageController = Get.find();
|
||
|
||
@override
|
||
void initState() {
|
||
super.initState();
|
||
String language = "zh_CN"; // 默认语言
|
||
int ent_type = AppConstants().ent_type;
|
||
if (mhLanguageController.selectLanguage.value?.language_code != null) {
|
||
language = mhLanguageController.selectLanguage.value!.language_code!;
|
||
} // 根据 ent_type 拼接不同的文件名
|
||
String pdfName =
|
||
ent_type == 1 ? "$language.pdf" : "${language}_$ent_type.pdf";
|
||
|
||
pdfController.loadPdf(
|
||
2,
|
||
"https://vsbst-api.he-info.cn/vsbs_sotrage/privacy-scheme/$pdfName",
|
||
);
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return LayoutBuilder(
|
||
builder: (context, bodySize) => GestureDetector(
|
||
// onTap: () => FocusScope.of(context).unfocus(),,
|
||
child: Container(
|
||
decoration: BoxDecoration(
|
||
image: DecorationImage(
|
||
image: AssetImage('assets/images/new_background.png'), // 本地图片
|
||
fit: BoxFit.fill, // 填满整个 Container
|
||
),
|
||
),
|
||
child: Scaffold(
|
||
backgroundColor: Colors.transparent, // 加上这一行
|
||
appBar: AppBar(
|
||
systemOverlayStyle: SystemUiOverlayStyle(
|
||
statusBarColor: Colors.transparent, // 状态栏背景色
|
||
statusBarIconBrightness: Brightness.light, // 图标颜色(Android)
|
||
statusBarBrightness: Brightness.light, // 图标颜色(iOS)
|
||
),
|
||
backgroundColor: themeController.currentColor.sc17,
|
||
automaticallyImplyLeading: false,
|
||
iconTheme: IconThemeData(
|
||
color: themeController.currentColor.sc3,
|
||
),
|
||
titleSpacing: 0,
|
||
// leading: returnIconButtom,
|
||
title: Container(
|
||
width: double.infinity,
|
||
height: 180.rpx,
|
||
child: Stack(
|
||
alignment: Alignment.center,
|
||
children: [
|
||
/// 居中标题
|
||
Text(
|
||
'隐私协议'.tr,
|
||
style: TextStyle(
|
||
fontFamily: 'Readex Pro',
|
||
color: themeController.currentColor.sc3,
|
||
letterSpacing: 0,
|
||
fontSize: 30.rpx,
|
||
),
|
||
),
|
||
|
||
/// 左边返回按钮
|
||
Positioned(
|
||
left: 0,
|
||
child: returnIconButtomNew(),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
|
||
actions: [],
|
||
centerTitle: false,
|
||
),
|
||
body: SafeArea(
|
||
top: true,
|
||
child: Padding(
|
||
padding: EdgeInsets.symmetric(horizontal: 0.rpx),
|
||
child: Column(
|
||
children: [
|
||
Expanded(
|
||
child: Obx(() {
|
||
if (pdfController.localPdfPath.value == null) {
|
||
return Center(
|
||
child: CircularProgressIndicator(
|
||
strokeWidth: 2,
|
||
valueColor: AlwaysStoppedAnimation<Color>(
|
||
themeController.currentColor.sc1,
|
||
),
|
||
),
|
||
);
|
||
} else {
|
||
return PDFView(
|
||
filePath: pdfController.localPdfPath.value!,
|
||
autoSpacing: false,
|
||
enableSwipe: true,
|
||
swipeHorizontal: false,
|
||
pageSnap: true,
|
||
fitEachPage: true,
|
||
defaultPage: 0,
|
||
onRender: (pages) => print('PDF 渲染完成,共 $pages 页'),
|
||
onError: (error) => print('PDF 加载错误: $error'),
|
||
);
|
||
}
|
||
}),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
}
|