Files
tools/lib/views/steps/review_install_view.dart
2026-04-07 11:38:37 +03:00

121 lines
4.2 KiB
Dart
Raw Permalink 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/material.dart';
import 'package:tools/def.dart';
import 'package:tools/models/device.dart';
import 'package:tools/models/post_install_options.dart';
class ReviewInstallView extends StatelessWidget {
const ReviewInstallView({
super.key,
required this.network,
required this.prefix,
required this.selectedImage,
required this.scriptDestination,
required this.localScriptPath,
required this.remoteScriptUrl,
required this.rebootAfterInstall,
required this.postInstallOptionsByDevice,
required this.selectedDevices,
required this.onStartInstall,
});
final String network;
final int prefix;
final String selectedImage;
final ScriptDestination scriptDestination;
final String localScriptPath;
final String remoteScriptUrl;
final bool rebootAfterInstall;
final Map<String, PostInstallOptions> postInstallOptionsByDevice;
final List<Device> selectedDevices;
final VoidCallback onStartInstall;
String get _scriptSource {
return switch (scriptDestination) {
ScriptDestination.self => 'Встроенный скрипт',
ScriptDestination.local => localScriptPath,
ScriptDestination.remote => remoteScriptUrl,
};
}
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Проверьте параметры перед запуском',
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 12),
Expanded(
child: ListView(
children: [
ListTile(
title: const Text('Сеть'),
subtitle: Text('$network/$prefix'),
),
ListTile(
title: const Text('Образ'),
subtitle: Text(selectedImage),
),
ListTile(
title: const Text('Источник скрипта'),
subtitle: Text(
_scriptSource.isEmpty ? 'Не указан' : _scriptSource,
),
),
ListTile(
title: const Text('Перезагрузка после установки'),
subtitle: Text(rebootAfterInstall ? 'Да' : 'Нет'),
),
ListTile(
title: const Text('Пост-установка'),
subtitle: Text(
'Настройки заданы для ${selectedDevices.length} устройств',
),
),
ListTile(
title: const Text('Выбранные устройства'),
subtitle: Text('${selectedDevices.length} шт.'),
),
const Divider(),
...selectedDevices.map(
(device) => ListTile(
dense: true,
title: Text(device.address),
subtitle: Text(_devicePostInstallSummary(device)),
trailing: device.isOrange
? const Chip(label: Text('Orange Pi'))
: null,
),
),
],
),
),
const SizedBox(height: 12),
SizedBox(
width: double.infinity,
child: FilledButton.icon(
onPressed: onStartInstall,
icon: const Icon(Icons.play_arrow),
label: const Text('Начать установку'),
),
),
],
);
}
String _devicePostInstallSummary(Device device) {
final options =
postInstallOptionsByDevice[device.address] ??
const PostInstallOptions();
return 'dhcp: ${options.useDhcp ? 'on' : 'off'}, '
'${options.useDhcp ? '' : 'network: ${options.staticNetwork}/${options.staticPrefix}, '}'
'archive: ${options.archiveName.isEmpty ? 'not set' : options.archiveName}, '
'device: ${options.deviceType}, '
'root pass: ${options.changeRootPassword ? 'set' : 'skip'}, '
'trombon pass: ${options.changeTrombonPassword ? 'set' : 'skip'}, '
'MAC: ${device.mac.isEmpty ? 'unknown' : device.mac}';
}
}