2025-04-18 17:50:46 +08:00
|
|
|
import 'dart:async';
|
|
|
|
|
|
2024-04-30 23:38:49 +08:00
|
|
|
import 'package:fl_clash/common/common.dart';
|
2025-04-18 17:50:46 +08:00
|
|
|
import 'package:fl_clash/providers/config.dart';
|
2024-04-30 23:38:49 +08:00
|
|
|
import 'package:fl_clash/state.dart';
|
2024-07-21 21:51:56 +08:00
|
|
|
import 'package:fl_clash/widgets/list.dart';
|
2024-04-30 23:38:49 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2025-04-18 17:50:46 +08:00
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2024-04-30 23:38:49 +08:00
|
|
|
|
2024-07-21 21:51:56 +08:00
|
|
|
@immutable
|
|
|
|
|
class Contributor {
|
|
|
|
|
final String avatar;
|
|
|
|
|
final String name;
|
|
|
|
|
final String link;
|
|
|
|
|
|
|
|
|
|
const Contributor({
|
|
|
|
|
required this.avatar,
|
|
|
|
|
required this.name,
|
|
|
|
|
required this.link,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-30 23:38:49 +08:00
|
|
|
class AboutFragment extends StatelessWidget {
|
|
|
|
|
const AboutFragment({super.key});
|
|
|
|
|
|
2024-05-20 15:15:09 +08:00
|
|
|
_checkUpdate(BuildContext context) async {
|
|
|
|
|
final commonScaffoldState = context.commonScaffoldState;
|
|
|
|
|
if (commonScaffoldState?.mounted != true) return;
|
2024-07-21 21:51:56 +08:00
|
|
|
final data = await commonScaffoldState?.loadingRun<Map<String, dynamic>?>(
|
2024-06-03 18:02:05 +08:00
|
|
|
request.checkForUpdate,
|
2024-05-20 15:15:09 +08:00
|
|
|
title: appLocalizations.checkUpdate,
|
|
|
|
|
);
|
2024-05-31 09:59:18 +08:00
|
|
|
globalState.appController.checkUpdateResultHandle(
|
2024-06-03 18:02:05 +08:00
|
|
|
data: data,
|
2024-05-31 09:59:18 +08:00
|
|
|
handleError: true,
|
|
|
|
|
);
|
2024-05-20 15:15:09 +08:00
|
|
|
}
|
|
|
|
|
|
2024-07-21 21:51:56 +08:00
|
|
|
List<Widget> _buildMoreSection(BuildContext context) {
|
|
|
|
|
return generateSection(
|
|
|
|
|
separated: false,
|
|
|
|
|
title: appLocalizations.more,
|
|
|
|
|
items: [
|
|
|
|
|
ListItem(
|
2024-04-30 23:38:49 +08:00
|
|
|
title: Text(appLocalizations.checkUpdate),
|
2024-05-31 09:59:18 +08:00
|
|
|
onTap: () {
|
2024-05-20 15:15:09 +08:00
|
|
|
_checkUpdate(context);
|
2024-04-30 23:38:49 +08:00
|
|
|
},
|
|
|
|
|
),
|
2025-04-18 17:50:46 +08:00
|
|
|
ListItem(
|
|
|
|
|
title: Text(appLocalizations.contactMe),
|
|
|
|
|
onTap: () {
|
|
|
|
|
globalState.showMessage(
|
|
|
|
|
title: appLocalizations.contactMe,
|
|
|
|
|
message: TextSpan(text: "chen08209@gmail.com"),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
2024-07-21 21:51:56 +08:00
|
|
|
ListItem(
|
2024-05-06 14:03:45 +08:00
|
|
|
title: const Text("Telegram"),
|
|
|
|
|
onTap: () {
|
2024-07-21 21:51:56 +08:00
|
|
|
globalState.openUrl(
|
2024-09-09 09:48:26 +08:00
|
|
|
"https://t.me/FlClash",
|
2024-05-06 14:03:45 +08:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
trailing: const Icon(Icons.launch),
|
|
|
|
|
),
|
2024-07-21 21:51:56 +08:00
|
|
|
ListItem(
|
2024-04-30 23:38:49 +08:00
|
|
|
title: Text(appLocalizations.project),
|
|
|
|
|
onTap: () {
|
2024-07-21 21:51:56 +08:00
|
|
|
globalState.openUrl(
|
|
|
|
|
"https://github.com/$repository",
|
2024-04-30 23:38:49 +08:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
trailing: const Icon(Icons.launch),
|
|
|
|
|
),
|
2024-07-21 21:51:56 +08:00
|
|
|
ListItem(
|
2024-04-30 23:38:49 +08:00
|
|
|
title: Text(appLocalizations.core),
|
|
|
|
|
onTap: () {
|
2024-07-21 21:51:56 +08:00
|
|
|
globalState.openUrl(
|
|
|
|
|
"https://github.com/chen08209/Clash.Meta/tree/FlClash",
|
2024-04-30 23:38:49 +08:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
trailing: const Icon(Icons.launch),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-07-21 21:51:56 +08:00
|
|
|
|
|
|
|
|
List<Widget> _buildContributorsSection() {
|
|
|
|
|
const contributors = [
|
|
|
|
|
Contributor(
|
|
|
|
|
avatar: "assets/images/avatars/june2.jpg",
|
|
|
|
|
name: "June2",
|
|
|
|
|
link: "https://t.me/Jibadong",
|
|
|
|
|
),
|
|
|
|
|
Contributor(
|
|
|
|
|
avatar: "assets/images/avatars/arue.jpg",
|
|
|
|
|
name: "Arue",
|
|
|
|
|
link: "https://t.me/xrcm6868",
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
return generateSection(
|
|
|
|
|
separated: false,
|
2024-07-24 01:27:49 +08:00
|
|
|
title: appLocalizations.otherContributors,
|
2024-07-21 21:51:56 +08:00
|
|
|
items: [
|
|
|
|
|
ListItem(
|
|
|
|
|
title: SingleChildScrollView(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
child: Wrap(
|
|
|
|
|
spacing: 24,
|
|
|
|
|
children: [
|
|
|
|
|
for (final contributor in contributors)
|
|
|
|
|
Avatar(
|
|
|
|
|
contributor: contributor,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final items = [
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
2025-04-18 17:50:46 +08:00
|
|
|
Consumer(builder: (_, ref, ___) {
|
|
|
|
|
return _DeveloperModeDetector(
|
|
|
|
|
child: Wrap(
|
|
|
|
|
spacing: 16,
|
|
|
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
2024-07-21 21:51:56 +08:00
|
|
|
children: [
|
2025-04-18 17:50:46 +08:00
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
'assets/images/icon.png',
|
|
|
|
|
width: 64,
|
|
|
|
|
height: 64,
|
|
|
|
|
),
|
2024-07-21 21:51:56 +08:00
|
|
|
),
|
2025-04-18 17:50:46 +08:00
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
appName,
|
|
|
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
globalState.packageInfo.version,
|
|
|
|
|
style: Theme.of(context).textTheme.labelLarge,
|
|
|
|
|
)
|
|
|
|
|
],
|
2024-07-21 21:51:56 +08:00
|
|
|
)
|
|
|
|
|
],
|
2025-04-18 17:50:46 +08:00
|
|
|
),
|
|
|
|
|
onEnterDeveloperMode: () {
|
|
|
|
|
ref.read(appSettingProvider.notifier).updateState(
|
|
|
|
|
(state) => state.copyWith(developerMode: true),
|
|
|
|
|
);
|
|
|
|
|
context.showNotifier(appLocalizations.developerModeEnableTip);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}),
|
2024-07-21 21:51:56 +08:00
|
|
|
const SizedBox(
|
|
|
|
|
height: 24,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
appLocalizations.desc,
|
|
|
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 12,
|
|
|
|
|
),
|
|
|
|
|
..._buildContributorsSection(),
|
|
|
|
|
..._buildMoreSection(context),
|
|
|
|
|
];
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: kMaterialListPadding.copyWith(
|
|
|
|
|
top: 16,
|
|
|
|
|
bottom: 16,
|
|
|
|
|
),
|
|
|
|
|
child: generateListView(items),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Avatar extends StatelessWidget {
|
|
|
|
|
final Contributor contributor;
|
|
|
|
|
|
|
|
|
|
const Avatar({
|
|
|
|
|
super.key,
|
|
|
|
|
required this.contributor,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return InkWell(
|
|
|
|
|
splashColor: Colors.transparent,
|
|
|
|
|
highlightColor: Colors.transparent,
|
|
|
|
|
hoverColor: Colors.transparent,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 36,
|
|
|
|
|
height: 36,
|
|
|
|
|
child: CircleAvatar(
|
|
|
|
|
foregroundImage: AssetImage(
|
|
|
|
|
contributor.avatar,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
contributor.name,
|
|
|
|
|
style: context.textTheme.bodySmall,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
onTap: () {
|
|
|
|
|
globalState.openUrl(contributor.link);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-04-30 23:38:49 +08:00
|
|
|
}
|
2025-04-18 17:50:46 +08:00
|
|
|
|
|
|
|
|
class _DeveloperModeDetector extends StatefulWidget {
|
|
|
|
|
final Widget child;
|
|
|
|
|
final VoidCallback onEnterDeveloperMode;
|
|
|
|
|
|
|
|
|
|
const _DeveloperModeDetector({
|
|
|
|
|
required this.child,
|
|
|
|
|
required this.onEnterDeveloperMode,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<_DeveloperModeDetector> createState() => _DeveloperModeDetectorState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _DeveloperModeDetectorState extends State<_DeveloperModeDetector> {
|
|
|
|
|
int _counter = 0;
|
|
|
|
|
Timer? _timer;
|
|
|
|
|
|
|
|
|
|
void _handleTap() {
|
|
|
|
|
_counter++;
|
|
|
|
|
if (_counter >= 5) {
|
|
|
|
|
widget.onEnterDeveloperMode();
|
|
|
|
|
_resetCounter();
|
|
|
|
|
} else {
|
|
|
|
|
_timer?.cancel();
|
|
|
|
|
_timer = Timer(Duration(seconds: 1), _resetCounter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _resetCounter() {
|
|
|
|
|
_counter = 0;
|
|
|
|
|
_timer?.cancel();
|
|
|
|
|
_timer = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_timer?.cancel();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: _handleTap,
|
|
|
|
|
child: widget.child,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|