mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
新增订阅管理
新增环境变量导入和导出
This commit is contained in:
181
lib/module/others/subscription/subscription_time_log_page.dart
Normal file
181
lib/module/others/subscription/subscription_time_log_page.dart
Normal file
@@ -0,0 +1,181 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:qinglong_app/base/http/api.dart';
|
||||
import 'package:qinglong_app/base/http/http.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_page.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_page.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_page.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_page.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_page.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_page.dart';
|
||||
import 'package:qinglong_app/module/others/subscription/subscription_page.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../../base/ui/lazy_load_state.dart';
|
||||
|
||||
class SubscriptionTimeLogPage extends StatefulWidget {
|
||||
final int subId;
|
||||
final bool needTimer;
|
||||
final String title;
|
||||
|
||||
const SubscriptionTimeLogPage(this.subId, this.needTimer, this.title, {Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_SubscriptionTimeLogPageState createState() => _SubscriptionTimeLogPageState();
|
||||
}
|
||||
|
||||
class _SubscriptionTimeLogPageState extends State<SubscriptionTimeLogPage>
|
||||
with LazyLoadState<SubscriptionTimeLogPage> {
|
||||
Timer? _timer;
|
||||
|
||||
String? content;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
bool isRequest = false;
|
||||
bool canRequest = true;
|
||||
|
||||
getLogData() async {
|
||||
if (!canRequest) return;
|
||||
if (isRequest) return;
|
||||
isRequest = true;
|
||||
HttpResponse<String> response = await Api.subTimeLog(widget.subId);
|
||||
if (response.success) {
|
||||
content = response.bean;
|
||||
setState(() {});
|
||||
}
|
||||
isRequest = false;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Icon(
|
||||
CupertinoIcons.chevron_down,
|
||||
size: 18,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
widget.title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Share.share(content ?? "");
|
||||
},
|
||||
child: const Icon(
|
||||
CupertinoIcons.share,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
if (content == null)
|
||||
const Expanded(
|
||||
child: Center(
|
||||
child: CupertinoActivityIndicator(),
|
||||
),
|
||||
)
|
||||
else
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
primary: true,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SelectableText(
|
||||
content!,
|
||||
scrollPhysics: const NeverScrollableScrollPhysics(),
|
||||
onSelectionChanged: (TextSelection selection,
|
||||
SelectionChangedCause? cause) {
|
||||
final int newStart = min(
|
||||
selection.baseOffset, selection.extentOffset);
|
||||
final int newEnd = max(
|
||||
selection.baseOffset, selection.extentOffset);
|
||||
if (newEnd == newStart) {
|
||||
canRequest = true;
|
||||
} else {
|
||||
canRequest = false;
|
||||
}
|
||||
},
|
||||
selectionHeightStyle: BoxHeightStyle.max,
|
||||
selectionWidthStyle: BoxWidthStyle.max,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 400,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onLazyLoad() {
|
||||
if (widget.needTimer) {
|
||||
_timer = Timer.periodic(
|
||||
const Duration(seconds: 2),
|
||||
(timer) {
|
||||
getLogData();
|
||||
},
|
||||
);
|
||||
} else {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
getLogData();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user