feat(patches-selector): show New tag for new patches (#1099)

This commit is contained in:
aAbed 2023-08-07 21:13:09 +05:45 committed by GitHub
parent 131df28110
commit 1714c3fa86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 108 additions and 17 deletions

View file

@ -16,6 +16,7 @@ class PatchItem extends StatefulWidget {
required this.packageVersion,
required this.supportedPackageVersions,
required this.isUnsupported,
required this.isNew,
required this.isSelected,
required this.onChanged,
this.child,
@ -26,6 +27,7 @@ class PatchItem extends StatefulWidget {
final String packageVersion;
final List<String> supportedPackageVersions;
final bool isUnsupported;
final bool isNew;
bool isSelected;
final Function(bool) onChanged;
final Widget? child;
@ -132,12 +134,12 @@ class _PatchItemState extends State<PatchItem> {
),
],
),
if (widget.isUnsupported &&
widget._managerAPI.areExperimentalPatchesEnabled())
Row(
children: <Widget>[
Row(
children: [
if (widget.isUnsupported &&
widget._managerAPI.areExperimentalPatchesEnabled())
Padding(
padding: const EdgeInsets.only(top: 8),
padding: const EdgeInsets.only(top: 8, right: 8),
child: TextButton.icon(
label: I18nText('warning'),
icon: const Icon(Icons.warning, size: 20.0),
@ -160,10 +162,33 @@ class _PatchItemState extends State<PatchItem> {
),
),
),
],
)
else
Container(),
if (widget.isNew)
Padding(
padding: const EdgeInsets.only(top: 8),
child: TextButton.icon(
label: I18nText('new'),
icon: const Icon(Icons.star, size: 20.0),
onPressed: () => _showNewPatchDialog(),
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,
),
),
),
)
],
),
widget.child ?? const SizedBox(),
],
),
@ -195,4 +220,23 @@ class _PatchItemState extends State<PatchItem> {
),
);
}
Future<void> _showNewPatchDialog() {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('patchItem.newPatch'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText(
'patchItem.newPatchDialogText',
),
actions: <Widget>[
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
}
}