Tweak titling and add user button, wrap in ResponsiveMaxWidth

merge-requests/67/merge
Hank Grabowski 2023-04-21 09:54:34 -04:00
rodzic 646f576016
commit abe5210728
1 zmienionych plików z 115 dodań i 98 usunięć

Wyświetl plik

@ -5,11 +5,13 @@ import 'package:result_monad/result_monad.dart';
import '../controls/linear_status_indicator.dart';
import '../controls/padding.dart';
import '../controls/responsive_max_width.dart';
import '../controls/standard_appbar.dart';
import '../controls/status_and_refresh_button.dart';
import '../globals.dart';
import '../models/connection.dart';
import '../models/group_data.dart';
import '../routes.dart';
import '../services/connections_manager.dart';
import '../services/network_status_service.dart';
import '../utils/active_profile_selector.dart';
@ -18,7 +20,7 @@ import '../utils/snackbar_builder.dart';
class GroupEditorScreen extends StatefulWidget {
final String groupId;
GroupEditorScreen({super.key, required this.groupId});
const GroupEditorScreen({super.key, required this.groupId});
@override
State<GroupEditorScreen> createState() => _GroupEditorScreenState();
@ -135,116 +137,131 @@ class _GroupEditorScreenState extends State<GroupEditorScreen> {
onRefresh: () async {
manager.refreshGroups();
},
child: Column(
children: [
StandardLinearProgressIndicator(nss.connectionUpdateStatus),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: TextFormField(
enabled: allowNameEditing,
readOnly: !allowNameEditing,
onEditingComplete: () async {
if (processingUpdate) {
return;
}
updateGroupName(context, manager);
},
onTapOutside: (_) async {
if (processingUpdate) {
return;
}
updateGroupName(context, manager);
},
controller: groupTextController,
textCapitalization: TextCapitalization.sentences,
decoration: InputDecoration(
labelText: 'Group Name',
border: OutlineInputBorder(
borderSide: const BorderSide(),
borderRadius: BorderRadius.circular(5.0),
child: ResponsiveMaxWidth(
child: Column(
children: [
StandardLinearProgressIndicator(nss.connectionUpdateStatus),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: TextFormField(
enabled: allowNameEditing,
readOnly: !allowNameEditing,
onEditingComplete: () async {
if (processingUpdate) {
return;
}
updateGroupName(context, manager);
},
onTapOutside: (_) async {
if (processingUpdate) {
return;
}
updateGroupName(context, manager);
},
controller: groupTextController,
textCapitalization: TextCapitalization.sentences,
decoration: InputDecoration(
labelText: 'Group Name',
border: OutlineInputBorder(
borderSide: const BorderSide(),
borderRadius: BorderRadius.circular(5.0),
),
),
),
),
),
const HorizontalPadding(),
IconButton(
onPressed: () {
if (allowNameEditing) {
groupTextController.text = groupData.name;
}
setState(() {
allowNameEditing = !allowNameEditing;
});
},
icon: const Icon(Icons.edit),
),
],
),
),
const VerticalPadding(),
ElevatedButton(
onPressed: () {}, child: const Text('Add Users')),
Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
onChanged: (value) {
const HorizontalPadding(),
IconButton(
onPressed: () {
if (allowNameEditing) {
groupTextController.text = groupData.name;
}
setState(() {
filterText = value.toLowerCase();
allowNameEditing = !allowNameEditing;
});
},
decoration: InputDecoration(
labelText: 'Filter By Name',
alignLabelWithHint: true,
border: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).highlightColor,
icon: const Icon(Icons.edit),
),
],
),
),
const VerticalPadding(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Group Members:',
style: Theme.of(context).textTheme.headlineSmall),
IconButton(
onPressed: () {
context.push(
'${ScreenPaths.groupManagement}/add_users/${widget.groupId}');
},
icon: const Icon(Icons.add)),
],
),
Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
onChanged: (value) {
setState(() {
filterText = value.toLowerCase();
});
},
decoration: InputDecoration(
labelText: 'Filter By Name',
alignLabelWithHint: true,
border: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).highlightColor,
),
borderRadius: BorderRadius.circular(5.0),
),
borderRadius: BorderRadius.circular(5.0),
),
),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: StatusAndRefreshButton(
valueListenable: nss.connectionUpdateStatus,
refreshFunction: () async =>
manager.refreshGroupMemberships(groupData),
),
)
],
),
Expanded(
child: ListView.separated(
physics: const AlwaysScrollableScrollPhysics(),
itemBuilder: (context, index) {
final m = members[index];
return ListTile(
title: Text(
'${m.name} (${m.handle})',
softWrap: true,
Padding(
padding: const EdgeInsets.all(8.0),
child: StatusAndRefreshButton(
valueListenable: nss.connectionUpdateStatus,
refreshFunction: () async =>
manager.refreshGroupMemberships(groupData),
),
subtitle: Text(
'Last Status: ${m.lastStatus?.toIso8601String() ?? "Unknown"}'),
trailing: IconButton(
onPressed: () async =>
removeUserFromGroup(manager, m),
icon: const Icon(Icons.remove),
),
);
},
separatorBuilder: (_, __) => const Divider(),
itemCount: members.length,
)
],
),
),
],
Expanded(
child: ListView.separated(
physics: const AlwaysScrollableScrollPhysics(),
itemBuilder: (context, index) {
final m = members[index];
return ListTile(
title: Text(
'${m.name} (${m.handle})',
softWrap: true,
),
subtitle: Text(
'Last Status: ${m.lastStatus?.toIso8601String() ?? "Unknown"}',
softWrap: true,
),
trailing: IconButton(
onPressed: () async =>
removeUserFromGroup(manager, m),
icon: const Icon(Icons.remove),
),
);
},
separatorBuilder: (_, __) => const Divider(),
itemCount: members.length,
),
),
],
),
),
),
));