Skip to content

Commit

Permalink
Merge branch 'main' into feat/snap-report
Browse files Browse the repository at this point in the history
  • Loading branch information
BLKKKBVSIK authored Jan 8, 2024
2 parents 8633fae + 943f07e commit ba19b75
Show file tree
Hide file tree
Showing 18 changed files with 412 additions and 107 deletions.
2 changes: 1 addition & 1 deletion packages/app_center/assets/app-center.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Type=Application
Version=1.0
Exec=snap-store %U
Icon=software-store
Icon=bin/data/flutter_assets/assets/app-center.png
Terminal=false
Categories=System;Utility;PackageManager;SoftwareManagement;Network;Settings;
Keywords=Ubuntu;Applications;Apps;Store;Software;Snaps;
Expand Down
2 changes: 2 additions & 0 deletions packages/app_center/lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ const kShimmerBaseLight = Color.fromARGB(120, 228, 228, 228);
const kShimmerBaseDark = Color.fromARGB(255, 51, 51, 51);
const kShimmerHighLightLight = Color.fromARGB(200, 247, 247, 247);
const kShimmerHighLightDark = Color.fromARGB(255, 57, 57, 57);

const kCircularProgressIndicatorHeight = 16.0;
2 changes: 1 addition & 1 deletion packages/app_center/lib/src/deb/deb_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DebModel extends ChangeNotifier {
AsyncValue<void> _state;

PackageKitPackageInfo? packageInfo;
bool get isInstalled => packageInfo!.info == PackageKitInfo.installed;
bool get isInstalled => packageInfo?.info == PackageKitInfo.installed;

Stream<PackageKitServiceError> get errorStream => packageKit.errorStream;

Expand Down
10 changes: 7 additions & 3 deletions packages/app_center/lib/src/deb/deb_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';

import 'package:app_center/appstream.dart';
import 'package:app_center/constants.dart';
import 'package:app_center/l10n.dart';
import 'package:app_center/layout.dart';
import 'package:app_center/src/deb/deb_model.dart';
Expand Down Expand Up @@ -79,7 +80,7 @@ class _DebView extends StatelessWidget {
final debInfos = <AppInfo>[
(
label: l10n.snapPageVersionLabel,
value: Text(debModel.packageInfo!.packageId.version)
value: Text(debModel.packageInfo?.packageId.version ?? '')
),
if (debModel.component.urls.isNotEmpty)
(
Expand Down Expand Up @@ -173,7 +174,7 @@ class _DebActionButtons extends ConsumerWidget {
.whenOrNull(data: (data) => data);
return Center(
child: SizedBox.square(
dimension: 16,
dimension: kCircularProgressIndicatorHeight,
child: YaruCircularProgressIndicator(
value: (transaction?.percentage ?? 0) / 100.0,
strokeWidth: 2,
Expand All @@ -195,7 +196,10 @@ class _DebActionButtons extends ConsumerWidget {
mainAxisSize: MainAxisSize.min,
overflowButtonSpacing: 8,
children: [
primaryActionButton,
if (debModel.packageInfo != null)
primaryActionButton
else
Text(l10n.debPageErrorNoPackageInfo),
if (debModel.activeTransactionId != null) cancelButton
].whereNotNull().toList(),
);
Expand Down
11 changes: 9 additions & 2 deletions packages/app_center/lib/src/explore/explore_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:app_center/l10n.dart';
import 'package:app_center/layout.dart';
import 'package:app_center/snapd.dart';
import 'package:app_center/src/store/store_pages.dart';
import 'package:app_center/store.dart';
import 'package:app_center/widgets.dart';
import 'package:collection/collection.dart';
Expand Down Expand Up @@ -172,8 +173,14 @@ class _CategoryBanner extends ConsumerWidget {
snaps: featuredSnaps?.take(kNumberOfBannerSnaps).toList() ?? [],
slogan: category.slogan(l10n),
buttonLabel: category.buttonLabel(l10n),
onPressed: () =>
StoreNavigator.pushSearch(context, category: category.categoryName),
onPressed: () {
if (displayedCategories.contains(category)) {
ref.read(yaruPageControllerProvider).index =
displayedCategories.indexOf(category) + 1;
} else {
StoreNavigator.pushSearch(context, category: category.categoryName);
}
},
colors: category.bannerColors,
);
}
Expand Down
5 changes: 3 additions & 2 deletions packages/app_center/lib/src/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"appCenterLabel": "App Center",
"appstreamSearchGreylist": "app;application;package;program;programme;suite;tool",
"snapPageChannelLabel": "Channel",
"snapPageConfinementLabel": "Confinement",
Expand Down Expand Up @@ -195,6 +196,6 @@
"snapReportPrivacyAgreementLabel": "In submitting this form, I confirm that I have read and agree to ",
"snapReportPrivacyAgreementCanonicalPrivacyNotice": "Canonical’s Privacy Notice ",
"snapReportPrivacyAgreementAndLabel": "and ",
"snapReportPrivacyAgreementPrivacyPolicy": "Privacy Policy"

"snapReportPrivacyAgreementPrivacyPolicy": "Privacy Policy",
"debPageErrorNoPackageInfo": "No package information found"
}
199 changes: 162 additions & 37 deletions packages/app_center/lib/src/manage/manage_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';

import 'package:app_center/constants.dart';
import 'package:app_center/l10n.dart';
import 'package:app_center/layout.dart';
import 'package:app_center/snapd.dart';
Expand Down Expand Up @@ -126,6 +127,7 @@ class _ManageView extends ConsumerWidget {
: index == 0
? ManageTilePosition.first
: ManageTilePosition.middle,
showUpdateButton: true,
),
),
SliverList.list(children: [
Expand Down Expand Up @@ -224,7 +226,7 @@ class _ActionButtons extends ConsumerWidget {
loading: () => (
l10n.managePageCheckingForUpdates,
const SizedBox(
height: 24,
height: kCircularProgressIndicatorHeight,
child: YaruCircularProgressIndicator(
strokeWidth: 4,
),
Expand All @@ -233,6 +235,9 @@ class _ActionButtons extends ConsumerWidget {
error: (_, __) => ('', const SizedBox.shrink()),
);

final updatesInprogress = updatesModel.refreshableSnapNames.isNotEmpty &&
!updatesModel.state.isLoading &&
updatesModel.activeChangeId != null;
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Expand Down Expand Up @@ -270,7 +275,7 @@ class _ActionButtons extends ConsumerWidget {
return Row(
children: [
SizedBox.square(
dimension: 16,
dimension: kCircularProgressIndicatorHeight,
child: YaruCircularProgressIndicator(
value: change?.progress,
strokeWidth: 2,
Expand Down Expand Up @@ -303,6 +308,19 @@ class _ActionButtons extends ConsumerWidget {
],
),
),
const SizedBox(width: 8),
PushButton.outlined(
onPressed: updatesInprogress
? () => ref
.read(updatesModelProvider)
.cancelChange(updatesModel.activeChangeId!)
: null,
child: Text(
l10n.snapActionCancelLabel,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
);
}
Expand All @@ -314,10 +332,12 @@ class _ManageSnapTile extends ConsumerWidget {
const _ManageSnapTile({
required this.snap,
this.position = ManageTilePosition.middle,
this.showUpdateButton = false,
});

final Snap snap;
final ManageTilePosition position;
final bool showUpdateButton;

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand Down Expand Up @@ -438,43 +458,148 @@ class _ManageSnapTile extends ConsumerWidget {
)
],
),
trailing: ButtonBar(
mainAxisSize: MainAxisSize.min,
children: [
Visibility(
maintainSize: true,
maintainAnimation: true,
maintainState: true,
visible: snapLauncher.isLaunchable,
child: OutlinedButton(
onPressed: snapLauncher.open,
child: Text(l10n.snapActionOpenLabel),
trailing: showUpdateButton
? buildButtonBarForUpdate(ref, l10n, snapLauncher, context)
: buildButtonBarForOpen(ref, l10n, snapLauncher, context),
);
}

ButtonBar buildButtonBarForUpdate(WidgetRef ref, AppLocalizations l10n,
SnapLauncher snapLauncher, BuildContext context) {
return ButtonBar(
mainAxisSize: MainAxisSize.min,
children: [
Consumer(
builder: (context, ref, child) {
final snapModel = ref.watch(snapModelProvider(snap.name));
final updatesModel = ref.watch(updatesModelProvider);

return PushButton.outlined(
onPressed: updatesModel.activeChangeId != null
? null
: () {
ref.read(snapModelProvider(snap.name)).refresh();
},
child: snapModel.activeChangeId != null
? Consumer(
builder: (context, ref, child) {
final change = ref
.watch(changeProvider(snapModel.activeChangeId))
.whenOrNull(data: (data) => data);
return Row(
children: [
SizedBox.square(
dimension: kCircularProgressIndicatorHeight,
child: YaruCircularProgressIndicator(
value: change?.progress,
strokeWidth: 2,
),
),
if (change != null) ...[
const SizedBox(width: 8),
Flexible(
child: Text(
change.localize(l10n) ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
]
],
);
},
)
: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(YaruIcons.download),
const SizedBox(width: 8),
Flexible(
child: Text(
l10n.snapActionUpdateLabel,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
);
},
),
MenuAnchor(
menuChildren: [
Visibility(
maintainSize: true,
maintainAnimation: true,
maintainState: true,
visible: snapLauncher.isLaunchable,
child: MenuItemButton(
onPressed: snapLauncher.open,
child: Text(l10n.snapActionOpenLabel),
),
),
MenuItemButton(
onPressed: () =>
StoreNavigator.pushSnap(context, name: snap.name),
child: Text(
l10n.managePageShowDetailsLabel,
style: Theme.of(context).textTheme.bodyMedium,
),
)
],
builder: (context, controller, child) => YaruOptionButton(
onPressed: () {
if (controller.isOpen) {
controller.close();
} else {
controller.open();
}
},
child: const Icon(YaruIcons.view_more_horizontal),
),
MenuAnchor(
menuChildren: [
MenuItemButton(
onPressed: () =>
StoreNavigator.pushSnap(context, name: snap.name),
child: Text(
l10n.managePageShowDetailsLabel,
style: Theme.of(context).textTheme.bodyMedium,
),
)
],
builder: (context, controller, child) => YaruOptionButton(
onPressed: () {
if (controller.isOpen) {
controller.close();
} else {
controller.open();
}
},
child: const Icon(YaruIcons.view_more_horizontal),
),
)
],
),
)
],
);
}

ButtonBar buildButtonBarForOpen(WidgetRef ref, AppLocalizations l10n,
SnapLauncher snapLauncher, BuildContext context) {
return ButtonBar(
mainAxisSize: MainAxisSize.min,
children: [
Visibility(
maintainSize: true,
maintainAnimation: true,
maintainState: true,
visible: snapLauncher.isLaunchable,
child: OutlinedButton(
onPressed: snapLauncher.open,
child: Text(l10n.snapActionOpenLabel),
),
),
MenuAnchor(
menuChildren: [
MenuItemButton(
onPressed: () =>
StoreNavigator.pushSnap(context, name: snap.name),
child: Text(
l10n.managePageShowDetailsLabel,
style: Theme.of(context).textTheme.bodyMedium,
),
)
],
builder: (context, controller, child) => YaruOptionButton(
onPressed: () {
if (controller.isOpen) {
controller.close();
} else {
controller.open();
}
},
child: const Icon(YaruIcons.view_more_horizontal),
),
)
],
);
}
}
11 changes: 9 additions & 2 deletions packages/app_center/lib/src/packagekit/packagekit_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,20 @@ class PackageKitService {
String name, [
@visibleForTesting String? architecture,
]) async {
final arch = architecture ?? await _getNativeArchitecture();
final possibleArchs = [
architecture ?? await _getNativeArchitecture(),
'all'
];
PackageKitPackageInfo? info;
await _createTransaction(
action: (transaction) => transaction.resolve([name]),
listener: (event) {
if (event is PackageKitPackageEvent && event.packageId.arch == arch) {
if (event is PackageKitPackageEvent &&
possibleArchs.contains(event.packageId.arch)) {
info = event;
} else {
log.error(
'Couldn\'t resolve package $name with architectures $possibleArchs');
}
},
).then(waitTransaction);
Expand Down
1 change: 1 addition & 0 deletions packages/app_center/lib/src/search/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SearchPage extends StatelessWidget {
Consumer(builder: (context, ref, child) {
final sortOrder = ref.watch(snapSortOrderProvider);
return MenuButtonBuilder<SnapSortOrder?>(
expanded: false,
values: const [
null,
SnapSortOrder.alphabeticalAsc,
Expand Down
Loading

0 comments on commit ba19b75

Please sign in to comment.