All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
84 lines
2.2 KiB
Dart
84 lines
2.2 KiB
Dart
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 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 textColor = Colors.blue;
|
|
final subTextColor = Colors.black;
|
|
|
|
final isActive = mount.state == Icons.toggle_on;
|
|
final nameText = SelectableText(
|
|
formatMountName(mount.type, mount.name),
|
|
style: TextStyle(color: subTextColor),
|
|
);
|
|
|
|
return ListTile(
|
|
isThreeLine: isActive,
|
|
leading: IconButton(
|
|
icon: Icon(Icons.settings, color: textColor),
|
|
onPressed: () {},
|
|
),
|
|
subtitle:
|
|
isActive
|
|
? Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
nameText,
|
|
SelectableText(
|
|
mount.path,
|
|
style: TextStyle(color: subTextColor),
|
|
),
|
|
],
|
|
)
|
|
: nameText,
|
|
title: SelectableText(
|
|
initialCaps(mount.type),
|
|
style: TextStyle(color: textColor, fontWeight: FontWeight.bold),
|
|
),
|
|
trailing: IconButton(
|
|
icon: Icon(
|
|
mount.state,
|
|
color: isActive ? Colors.blue : Colors.grey,
|
|
),
|
|
onPressed: () {},
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
@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();
|
|
});
|
|
}
|
|
}
|