mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-04-30 05:54:26 +02:00
feat(patches-selector): improve disabled card UI (#941)
This commit is contained in:
parent
5e7458ff1c
commit
b161608d02
@ -44,135 +44,136 @@ class _PatchItemState extends State<PatchItem> {
|
|||||||
widget.isSelected = widget.isSelected && (!widget.isUnsupported || widget._managerAPI.areExperimentalPatchesEnabled());
|
widget.isSelected = widget.isSelected && (!widget.isUnsupported || widget._managerAPI.areExperimentalPatchesEnabled());
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||||
child: CustomCard(
|
child: Opacity(
|
||||||
backgroundColor: widget.isUnsupported &&
|
opacity: widget.isUnsupported &&
|
||||||
widget._managerAPI.areExperimentalPatchesEnabled() == false
|
widget._managerAPI.areExperimentalPatchesEnabled() == false
|
||||||
? Theme.of(context).colorScheme.brightness == Brightness.light
|
? 0.5
|
||||||
? Colors.grey[400]
|
: 1,
|
||||||
: Colors.grey[700]
|
child: CustomCard(
|
||||||
: null,
|
onTap: () {
|
||||||
onTap: () {
|
setState(() {
|
||||||
setState(() {
|
if (widget.isUnsupported &&
|
||||||
if (widget.isUnsupported &&
|
!widget._managerAPI.areExperimentalPatchesEnabled()) {
|
||||||
!widget._managerAPI.areExperimentalPatchesEnabled()) {
|
widget.isSelected = false;
|
||||||
widget.isSelected = false;
|
widget.toast.showBottom('patchItem.unsupportedPatchVersion');
|
||||||
widget.toast.showBottom('patchItem.unsupportedPatchVersion');
|
} else {
|
||||||
} else {
|
widget.isSelected = !widget.isSelected;
|
||||||
widget.isSelected = !widget.isSelected;
|
}
|
||||||
}
|
});
|
||||||
});
|
widget.onChanged(widget.isSelected);
|
||||||
widget.onChanged(widget.isSelected);
|
},
|
||||||
},
|
child: Column(
|
||||||
child: Column(
|
children: <Widget>[
|
||||||
children: <Widget>[
|
Row(
|
||||||
Row(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
children: <Widget>[
|
||||||
children: <Widget>[
|
Flexible(
|
||||||
Flexible(
|
child: Column(
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
children: <Widget>[
|
||||||
children: <Widget>[
|
Row(
|
||||||
Row(
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
children: <Widget>[
|
||||||
children: <Widget>[
|
Expanded(
|
||||||
Expanded(
|
child: Text(
|
||||||
child: Text(
|
widget.simpleName,
|
||||||
widget.simpleName,
|
maxLines: 2,
|
||||||
maxLines: 2,
|
overflow: TextOverflow.visible,
|
||||||
overflow: TextOverflow.visible,
|
style: const TextStyle(
|
||||||
style: const TextStyle(
|
fontSize: 16,
|
||||||
fontSize: 16,
|
fontWeight: FontWeight.w600,
|
||||||
fontWeight: FontWeight.w600,
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 1),
|
||||||
|
Text(
|
||||||
|
widget.version,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
widget.description,
|
||||||
|
softWrap: true,
|
||||||
|
overflow: TextOverflow.visible,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onSecondaryContainer,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Transform.scale(
|
||||||
|
scale: 1.2,
|
||||||
|
child: Checkbox(
|
||||||
|
value: widget.isSelected,
|
||||||
|
activeColor: Theme.of(context).colorScheme.primary,
|
||||||
|
checkColor:
|
||||||
|
Theme.of(context).colorScheme.secondaryContainer,
|
||||||
|
side: BorderSide(
|
||||||
|
width: 2.0,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
onChanged: (newValue) {
|
||||||
|
setState(() {
|
||||||
|
if (widget.isUnsupported &&
|
||||||
|
!widget._managerAPI
|
||||||
|
.areExperimentalPatchesEnabled()) {
|
||||||
|
widget.isSelected = false;
|
||||||
|
widget.toast.showBottom(
|
||||||
|
'patchItem.unsupportedPatchVersion');
|
||||||
|
} else {
|
||||||
|
widget.isSelected = newValue!;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
widget.onChanged(widget.isSelected);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (widget.isUnsupported &&
|
||||||
|
widget._managerAPI.areExperimentalPatchesEnabled())
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 8),
|
||||||
|
child: TextButton.icon(
|
||||||
|
label: I18nText('warning'),
|
||||||
|
icon: const Icon(Icons.warning, size: 20.0),
|
||||||
|
onPressed: () => _showUnsupportedWarningDialog(),
|
||||||
|
style: ButtonStyle(
|
||||||
|
shape: MaterialStateProperty.all(
|
||||||
|
RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
side: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
backgroundColor: MaterialStateProperty.all(
|
||||||
),
|
Colors.transparent,
|
||||||
const SizedBox(height: 1),
|
),
|
||||||
Text(
|
foregroundColor: MaterialStateProperty.all(
|
||||||
widget.version,
|
Theme.of(context).colorScheme.secondary,
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
widget.description,
|
|
||||||
softWrap: true,
|
|
||||||
overflow: TextOverflow.visible,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onSecondaryContainer,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Transform.scale(
|
|
||||||
scale: 1.2,
|
|
||||||
child: Checkbox(
|
|
||||||
value: widget.isSelected,
|
|
||||||
activeColor: Theme.of(context).colorScheme.primary,
|
|
||||||
checkColor:
|
|
||||||
Theme.of(context).colorScheme.secondaryContainer,
|
|
||||||
side: BorderSide(
|
|
||||||
width: 2.0,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
onChanged: (newValue) {
|
|
||||||
setState(() {
|
|
||||||
if (widget.isUnsupported &&
|
|
||||||
!widget._managerAPI
|
|
||||||
.areExperimentalPatchesEnabled()) {
|
|
||||||
widget.isSelected = false;
|
|
||||||
widget.toast
|
|
||||||
.showBottom('patchItem.unsupportedPatchVersion');
|
|
||||||
} else {
|
|
||||||
widget.isSelected = newValue!;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
widget.onChanged(widget.isSelected);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (widget.isUnsupported)
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 8),
|
|
||||||
child: TextButton.icon(
|
|
||||||
label: I18nText('warning'),
|
|
||||||
icon: const Icon(Icons.warning, size: 20.0),
|
|
||||||
onPressed: () => _showUnsupportedWarningDialog(),
|
|
||||||
style: ButtonStyle(
|
|
||||||
shape: MaterialStateProperty.all(
|
|
||||||
RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
side: BorderSide(
|
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
backgroundColor: MaterialStateProperty.all(
|
|
||||||
Colors.transparent,
|
|
||||||
),
|
|
||||||
foregroundColor: MaterialStateProperty.all(
|
|
||||||
Theme.of(context).colorScheme.secondary,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
)
|
||||||
)
|
else
|
||||||
else
|
Container(),
|
||||||
Container(),
|
widget.child ?? const SizedBox(),
|
||||||
widget.child ?? const SizedBox(),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user