Compare commits

...

5 Commits

Author SHA1 Message Date
96df3168fc updates
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2025-03-01 15:50:01 -06:00
45381c3d0c updates 2025-03-01 15:48:40 -06:00
4c82b87b07 gui changes 2025-03-01 15:48:32 -06:00
c29072d84d gui changes 2025-03-01 15:47:34 -06:00
311a2688cb gui changes 2025-03-01 15:43:36 -06:00
3 changed files with 61 additions and 14 deletions

View File

@ -0,0 +1,18 @@
String formatMountName(String type, String name) {
if (type == "remote") {
return name.replaceAll("_", ":");
}
return name;
}
String initialCaps(String txt) {
if (txt.isEmpty) {
return txt;
}
if (txt.length == 1) {
return txt[0].toUpperCase();
}
return txt[0].toUpperCase() + txt.substring(1).toLowerCase();
}

View File

@ -1,5 +1,3 @@
import 'dart:convert';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
@ -8,12 +6,10 @@ class MountConfig {
String _path = "";
Map<String, dynamic> _settings = {};
IconData _state = Icons.toggle_off;
Map<String, dynamic> _status = {};
final String _type;
MountConfig({required name, required type}) : _name = name, _type = type;
UnmodifiableMapView get settings => UnmodifiableMapView(_settings);
UnmodifiableMapView get status => UnmodifiableMapView(_status);
String get name => _name;
String get path => _path;
@ -29,8 +25,7 @@ class MountConfig {
}
void updateStatus(Map<String, dynamic> status) {
_status = status;
_state = _status["Active"] as bool ? Icons.toggle_on : Icons.toggle_off;
_path = _status["Location"] as String;
_path = status["Location"] as String;
_state = status["Active"] as bool ? Icons.toggle_on : Icons.toggle_off;
}
}

View File

@ -1,27 +1,61 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:repertory/helpers.dart';
import 'package:repertory/models/mount.dart';
class MountWidget extends StatelessWidget {
class MountWidget extends StatefulWidget {
const MountWidget({super.key});
@override
State<MountWidget> createState() => _MountWidgetState();
}
class _MountWidgetState extends State<MountWidget> {
Timer? _timer;
@override
Widget build(BuildContext context) {
return Card(
child: Consumer<Mount>(
builder: (context, mount, widget) {
final isThreeLine = mount.state == Icons.toggle_on;
return ListTile(
isThreeLine: true,
isThreeLine: isThreeLine,
leading: const Icon(Icons.settings),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [Text(mount.name), Text(mount.path)],
),
title: Text(mount.type),
subtitle:
isThreeLine
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(formatMountName(mount.type, mount.name)),
Text(mount.path),
],
)
: Text(formatMountName(mount.type, mount.name)),
title: Text(initialCaps(mount.type)),
trailing: Icon(mount.state),
);
},
),
);
}
@override
void dispose() {
_timer?.cancel();
_timer = null;
super.dispose();
}
@override
void initState() {
super.initState();
_timer = Timer.periodic(const Duration(seconds: 5), (_) {
var provider = Provider.of<Mount>(context, listen: false);
provider.refresh();
});
}
}