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,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-02 02:24:12 +08:00
|
|
|
class AboutView extends StatelessWidget {
|
|
|
|
|
const AboutView({super.key});
|
2024-04-30 23:38:49 +08:00
|
|
|
|
2025-06-07 01:48:34 +08:00
|
|
|
Future<void> _checkUpdate(BuildContext context) async {
|
2024-05-20 15:15:09 +08:00
|
|
|
final commonScaffoldState = context.commonScaffoldState;
|
|
|
|
|
if (commonScaffoldState?.mounted != true) return;
|
2025-06-07 01:48:34 +08:00
|
|
|
final data = await globalState.appController.safeRun<Map<String, dynamic>?>(
|
2024-06-03 18:02:05 +08:00
|
|
|
request.checkForUpdate,
|
2024-05-20 15:15:09 +08:00
|
|
|
title: appLocalizations.checkUpdate,
|
2025-06-07 01:48:34 +08:00
|
|
|
needLoading: true,
|
2024-05-20 15:15:09 +08:00
|
|
|
);
|
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
|
|
|
},
|
|
|
|
|
),
|
2024-07-21 21:51:56 +08:00
|
|
|
ListItem(
|
2025-06-07 01:48:34 +08:00
|
|
|
title: const Text('Telegram'),
|
2024-05-06 14:03:45 +08:00
|
|
|
onTap: () {
|
2025-07-31 17:09:18 +08:00
|
|
|
globalState.openUrl('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: () {
|
2025-07-31 17:09:18 +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(
|
2025-06-07 01:48:34 +08:00
|
|
|
'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(
|
2025-06-07 01:48:34 +08:00
|
|
|
avatar: 'assets/images/avatars/june2.jpg',
|
|
|
|
|
name: 'June2',
|
|
|
|
|
link: 'https://t.me/Jibadong',
|
2024-07-21 21:51:56 +08:00
|
|
|
),
|
|
|
|
|
Contributor(
|
2025-06-07 01:48:34 +08:00
|
|
|
avatar: 'assets/images/avatars/arue.jpg',
|
|
|
|
|
name: 'Arue',
|
|
|
|
|
link: 'https://t.me/xrcm6868',
|
2024-07-21 21:51:56 +08:00
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
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)
|
2025-07-31 17:09:18 +08:00
|
|
|
Avatar(contributor: contributor),
|
2024-07-21 21:51:56 +08:00
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
2025-07-31 17:09:18 +08:00
|
|
|
),
|
2024-07-21 21:51:56 +08:00
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final items = [
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
2025-07-31 17:09:18 +08:00
|
|
|
Consumer(
|
|
|
|
|
builder: (_, ref, _) {
|
|
|
|
|
return _DeveloperModeDetector(
|
|
|
|
|
child: Wrap(
|
|
|
|
|
spacing: 16,
|
|
|
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
'assets/images/icon.png',
|
|
|
|
|
width: 64,
|
|
|
|
|
height: 64,
|
2025-04-18 17:50:46 +08:00
|
|
|
),
|
2025-07-31 17:09:18 +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,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
onEnterDeveloperMode: () {
|
|
|
|
|
ref
|
|
|
|
|
.read(appSettingProvider.notifier)
|
|
|
|
|
.updateState(
|
|
|
|
|
(state) => state.copyWith(developerMode: true),
|
|
|
|
|
);
|
|
|
|
|
context.showNotifier(
|
|
|
|
|
appLocalizations.developerModeEnableTip,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
2024-07-21 21:51:56 +08:00
|
|
|
),
|
2025-07-31 17:09:18 +08:00
|
|
|
const SizedBox(height: 24),
|
2024-07-21 21:51:56 +08:00
|
|
|
Text(
|
|
|
|
|
appLocalizations.desc,
|
|
|
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
2025-07-31 17:09:18 +08:00
|
|
|
const SizedBox(height: 12),
|
2024-07-21 21:51:56 +08:00
|
|
|
..._buildContributorsSection(),
|
|
|
|
|
..._buildMoreSection(context),
|
|
|
|
|
];
|
|
|
|
|
return Padding(
|
2025-07-31 17:09:18 +08:00
|
|
|
padding: kMaterialListPadding.copyWith(top: 16, bottom: 16),
|
2024-07-21 21:51:56 +08:00
|
|
|
child: generateListView(items),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Avatar extends StatelessWidget {
|
|
|
|
|
final Contributor contributor;
|
|
|
|
|
|
2025-07-31 17:09:18 +08:00
|
|
|
const Avatar({super.key, required this.contributor});
|
2024-07-21 21:51:56 +08:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2025-05-02 02:24:12 +08:00
|
|
|
return GestureDetector(
|
2024-07-21 21:51:56 +08:00
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 36,
|
|
|
|
|
height: 36,
|
|
|
|
|
child: CircleAvatar(
|
2025-07-31 17:09:18 +08:00
|
|
|
foregroundImage: AssetImage(contributor.avatar),
|
2024-07-21 21:51:56 +08:00
|
|
|
),
|
|
|
|
|
),
|
2025-07-31 17:09:18 +08:00
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
Text(contributor.name, style: context.textTheme.bodySmall),
|
2024-07-21 21:51:56 +08:00
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
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) {
|
2025-07-31 17:09:18 +08:00
|
|
|
return GestureDetector(onTap: _handleTap, child: widget.child);
|
2025-04-18 17:50:46 +08:00
|
|
|
}
|
|
|
|
|
}
|