Skip to content

Commit

Permalink
Fixes for confinement, license and version strings (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Sep 25, 2022
1 parent 85e67bf commit 3110536
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 90 deletions.
169 changes: 82 additions & 87 deletions lib/store_app/common/app_infos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import 'package:software/l10n/l10n.dart';
import 'package:software/store_app/common/constants.dart';
import 'package:yaru_icons/yaru_icons.dart';

const headerStyle = TextStyle(fontWeight: FontWeight.w500, fontSize: 14);

class AppInfos extends StatelessWidget {
const AppInfos({
Key? key,
Expand All @@ -31,6 +33,7 @@ class AppInfos extends StatelessWidget {
required this.version,
this.mainAxisAlignment = MainAxisAlignment.center,
this.versionChanged,
this.mainAxisSize = MainAxisSize.max,
}) : super(key: key);

final bool strict;
Expand All @@ -41,27 +44,22 @@ class AppInfos extends StatelessWidget {
final String version;
final MainAxisAlignment mainAxisAlignment;
final bool? versionChanged;
final MainAxisSize mainAxisSize;

@override
Widget build(BuildContext context) {
const headerStyle = TextStyle(fontWeight: FontWeight.w500, fontSize: 14);

return Row(
mainAxisAlignment: mainAxisAlignment,
mainAxisSize: MainAxisSize.max,
mainAxisSize: mainAxisSize,
children: [
_Confinement(
headerStyle: headerStyle,
strict: strict,
confinementName: confinementName,
),
const SizedBox(height: 40, width: 30, child: VerticalDivider()),
_License(headerStyle: headerStyle, license: license),
const SizedBox(height: 40, width: 30, child: VerticalDivider()),
_Version(
installDate: installDate,
headerStyle: headerStyle,
installDateIsoNorm: installDateIsoNorm,
version: version,
versionChanged: versionChanged,
),
Expand All @@ -70,53 +68,69 @@ class AppInfos extends StatelessWidget {
}
}

class _InfoColumn extends StatelessWidget {
const _InfoColumn({
Key? key,
required this.header,
required this.child,
required this.tooltipMessage,
}) : super(key: key);

final String header;
final String tooltipMessage;
final Widget child;

@override
Widget build(BuildContext context) {
return Tooltip(
message: tooltipMessage,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
header,
overflow: TextOverflow.ellipsis,
style: headerStyle,
),
SizedBox(
width: 100,
child: child,
),
],
),
);
}
}

class _Version extends StatelessWidget {
const _Version({
Key? key,
required this.installDate,
required this.headerStyle,
required this.installDateIsoNorm,
required this.version,
this.versionChanged,
}) : super(key: key);

final String installDate;
final TextStyle headerStyle;
final String installDateIsoNorm;
final String version;
final bool? versionChanged;

@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Text(
context.l10n.version,
overflow: TextOverflow.ellipsis,
style: headerStyle,
),
return _InfoColumn(
header: context.l10n.version,
tooltipMessage: version,
child: Text(
version,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: headerStyle.copyWith(
fontWeight: FontWeight.normal,
color: versionChanged == true
? Theme.of(context).brightness == Brightness.light
? positiveGreenLightTheme
: positiveGreenDarkTheme
: null,
),
Flexible(
child: Tooltip(
message: version,
child: Text(
version,
overflow: TextOverflow.ellipsis,
style: headerStyle.copyWith(
fontWeight: FontWeight.normal,
color: versionChanged == true
? Theme.of(context).brightness == Brightness.light
? positiveGreenLightTheme
: positiveGreenDarkTheme
: null,
),
),
),
),
],
),
);
}
}
Expand All @@ -133,70 +147,51 @@ class _License extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Text(context.l10n.license, style: headerStyle),
),
Flexible(
child: Tooltip(
message: license,
child: Text(
license.split(' ').first,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyMedium,
),
),
)
],
return _InfoColumn(
header: context.l10n.license,
tooltipMessage: license,
child: Text(
license,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyMedium,
),
);
}
}

class _Confinement extends StatelessWidget {
const _Confinement({
Key? key,
required this.headerStyle,
required this.strict,
required this.confinementName,
}) : super(key: key);

final TextStyle headerStyle;
final bool strict;
final String confinementName;

@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Text(
context.l10n.confinement,
style: headerStyle,
return _InfoColumn(
header: context.l10n.confinement,
tooltipMessage: confinementName,
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
strict ? YaruIcons.shield : YaruIcons.warning,
size: 18,
),
),
Flexible(
child: Row(
children: [
Icon(
strict ? YaruIcons.shield : YaruIcons.warning,
size: 18,
),
const SizedBox(
width: 5,
),
Text(
confinementName,
style: Theme.of(context).textTheme.bodyMedium,
),
],
const SizedBox(
width: 5,
),
),
],
Text(
confinementName,
style: Theme.of(context).textTheme.bodyMedium,
),
],
),
);
}
}
11 changes: 8 additions & 3 deletions lib/store_app/common/snap_channel_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ class SnapChannelPopupButton extends StatelessWidget {
.format(entry.value.releasedAt),
style: const TextStyle(fontWeight: FontWeight.w300),
),
trailing: Text(
entry.value.version,
style: channelTextTheme,
trailing: ConstrainedBox(
constraints:
const BoxConstraints(maxWidth: 180, minWidth: 80),
child: Text(
entry.value.version,
style: channelTextTheme,
textAlign: TextAlign.end,
),
),
),
)
Expand Down

0 comments on commit 3110536

Please sign in to comment.