Files
alan 502027b602 Remove Cupertino branches from server settings
Keep the public compatibility parameters while retaining only the Material UI path. Remove Cupertino-only tests so the reviewed settings and server code matches the app's Material-only runtime.
2026-11-11 01:39:39 +00:00

73 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import '../settings_group.dart';
import 'storage_controls.dart';
import 'storage_models.dart';
import '../../../core/api_gateway.dart';
class StorageUsage extends StatelessWidget {
const StorageUsage({super.key, required this.data});
final JsonMap data;
@override
Widget build(BuildContext context) => SettingsGroup(
title: 'Server storage',
footer: const Text(
'Combined file sizes on the connected server, with shared files counted once. Protected data may prevent reaching a size limit.',
),
children: [
storagePadding(
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${data['partial'] == true ? 'At least ' : ''}${storageBytes(storageInt(data['total_bytes']))} used',
style: DefaultTextStyle.of(
context,
).style.copyWith(fontWeight: FontWeight.bold),
),
if (_measured(context) case final String measured)
Text('Measured $measured'),
if (data['partial'] == true)
const Text('Measurement is incomplete. See details below.'),
],
),
),
for (final category in storageRows(data['categories']))
storagePadding(
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Wrap(
alignment: WrapAlignment.spaceBetween,
spacing: 16,
children: [
Text('${category['label'] ?? category['id']}'),
Text(
'${category['partial'] == true ? 'At least ' : ''}${storageBytes(storageInt(category['bytes']))}',
),
],
),
Text('${storageInt(category['files'])} files'),
if (category['path'] case final String path when path.isNotEmpty)
Text(path, softWrap: true),
if (category['error'] case final String error
when error.isNotEmpty)
Text(error),
],
),
),
if (data['warnings'] case final List warnings when warnings.isNotEmpty)
storagePadding(Text(warnings.join('\n'))),
],
);
String? _measured(BuildContext context) {
final time = DateTime.tryParse('${data['measured_at'] ?? ''}')?.toLocal();
if (time == null) return null;
final material = Localizations.of<MaterialLocalizations>(
context,
MaterialLocalizations,
);
if (material == null) return null;
return '${time.day} ${material.formatMonthYear(time)} · ${material.formatTimeOfDay(TimeOfDay.fromDateTime(time), alwaysUse24HourFormat: true)}';
}
}