Files
umbrix/lib/features/settings/about/licenses_screen.dart

93 lines
2.7 KiB
Dart
Raw Permalink Normal View History

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:umbrix/core/localization/translations.dart';
import 'package:umbrix/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,
),
),
);
},
),
),
],
),
);
}
}