refactor
This commit is contained in:
@@ -5,13 +5,13 @@ import 'package:repertory/constants.dart' as constants;
|
|||||||
|
|
||||||
class AppIconButtonFramed extends StatelessWidget {
|
class AppIconButtonFramed extends StatelessWidget {
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final VoidCallback? onTap;
|
final VoidCallback? onPressed;
|
||||||
final Color? iconColor;
|
final Color? iconColor;
|
||||||
|
|
||||||
const AppIconButtonFramed({
|
const AppIconButtonFramed({
|
||||||
super.key,
|
super.key,
|
||||||
required this.icon,
|
required this.icon,
|
||||||
this.onTap,
|
this.onPressed,
|
||||||
this.iconColor,
|
this.iconColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ class AppIconButtonFramed extends StatelessWidget {
|
|||||||
return Material(
|
return Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: onTap,
|
onTap: onPressed,
|
||||||
borderRadius: radius,
|
borderRadius: radius,
|
||||||
child: Ink(
|
child: Ink(
|
||||||
width: 46,
|
width: 46,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class AppToggleButtonFramed extends StatelessWidget {
|
|||||||
return AppIconButtonFramed(
|
return AppIconButtonFramed(
|
||||||
icon: icon,
|
icon: icon,
|
||||||
iconColor: iconColor,
|
iconColor: iconColor,
|
||||||
onTap: mounted == null ? null : onPressed,
|
onPressed: mounted == null ? null : onPressed,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class MountWidget extends StatefulWidget {
|
|||||||
class _MountWidgetState extends State<MountWidget>
|
class _MountWidgetState extends State<MountWidget>
|
||||||
with SafeSetState<MountWidget> {
|
with SafeSetState<MountWidget> {
|
||||||
bool _enabled = true;
|
bool _enabled = true;
|
||||||
bool _editEnabled = true;
|
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -68,13 +67,11 @@ class _MountWidgetState extends State<MountWidget>
|
|||||||
children: [
|
children: [
|
||||||
AppIconButtonFramed(
|
AppIconButtonFramed(
|
||||||
icon: Icons.settings,
|
icon: Icons.settings,
|
||||||
onTap: () {
|
onPressed: () => Navigator.pushNamed(
|
||||||
Navigator.pushNamed(
|
|
||||||
context,
|
context,
|
||||||
'/edit',
|
'/edit',
|
||||||
arguments: mount,
|
arguments: mount,
|
||||||
);
|
),
|
||||||
},
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: constants.padding),
|
const SizedBox(width: constants.padding),
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -89,13 +86,25 @@ class _MountWidgetState extends State<MountWidget>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!(mount.mounted ?? false))
|
if (mount.mounted == null) ...[
|
||||||
AppIconButtonFramed(
|
AppIconButtonFramed(
|
||||||
icon: Icons.delete,
|
icon: Icons.delete,
|
||||||
onTap: () async {
|
onPressed: _enabled
|
||||||
return mount.remove();
|
? () async {
|
||||||
},
|
setState(() {
|
||||||
|
_enabled = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
await mount.remove();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_enabled = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
|
SizedBox(width: constants.paddingSmall),
|
||||||
|
],
|
||||||
AppToggleButtonFramed(
|
AppToggleButtonFramed(
|
||||||
mounted: mount.mounted,
|
mounted: mount.mounted,
|
||||||
onPressed: _createMountHandler(context, mount),
|
onPressed: _createMountHandler(context, mount),
|
||||||
@@ -108,20 +117,17 @@ class _MountWidgetState extends State<MountWidget>
|
|||||||
AppOutlinedIconButton(
|
AppOutlinedIconButton(
|
||||||
text: 'Edit path',
|
text: 'Edit path',
|
||||||
icon: Icons.edit,
|
icon: Icons.edit,
|
||||||
enabled: mount.mounted == false,
|
enabled: _enabled && mount.mounted == false,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (!_editEnabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_editEnabled = false;
|
_enabled = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
final available = await mount.getAvailableLocations();
|
final available = await mount.getAvailableLocations();
|
||||||
|
|
||||||
if (!mounted) {
|
if (!mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_editEnabled = true;
|
_enabled = true;
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -141,7 +147,7 @@ class _MountWidgetState extends State<MountWidget>
|
|||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_editEnabled = true;
|
_enabled = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user