Files
umbrix/lib/features/settings/about/licenses_screen.dart
2026-01-15 12:28:40 +03:00

93 lines
2.7 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:hiddify/core/localization/translations.dart';
import 'package:hiddify/gen/assets.gen.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
class LicensesScreen extends HookConsumerWidget {
const LicensesScreen({super.key});
static Future<String> _loadAllLicenses() async {
final licenses = await LicenseRegistry.licenses.toList();
final buffer = StringBuffer();
for (final license in licenses) {
for (final package in license.packages) {
buffer.writeln(package);
}
buffer.writeln();
final paragraphs = license.paragraphs.toList();
for (final paragraph in paragraphs) {
buffer.writeln(paragraph.text);
}
buffer.writeln();
buffer.writeln('=' * 80);
buffer.writeln();
}
return buffer.toString();
}
@override
Widget build(BuildContext context, WidgetRef ref) {
final t = ref.watch(translationsProvider);
return Scaffold(
appBar: AppBar(
title: Text(t.about.licenses),
),
body: Column(
children: [
// Заголовок с логотипом
Container(
padding: const EdgeInsets.all(24),
child: Column(
children: [
Assets.images.umbrixLogo.image(
width: 64,
height: 64,
fit: BoxFit.contain,
),
const SizedBox(height: 12),
const Text(
'0.1.0',
style: TextStyle(fontSize: 16),
),
],
),
),
const Divider(height: 1),
// Весь текст лицензий
Expanded(
child: FutureBuilder<String>(
future: _loadAllLicenses(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
}
if (snapshot.hasError) {
return Center(child: Text('Ошибка: ${snapshot.error}'));
}
return SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: SelectableText(
snapshot.data ?? '',
style: const TextStyle(
fontSize: 5.5,
fontFamily: 'monospace',
height: 1.4,
),
),
);
},
),
),
],
),
);
}
}