Change borderRadius and padding in AppListItem

This commit is contained in:
Elias Bonnici 2024-08-08 13:06:34 +02:00
parent 5565382969
commit cbedbfae4e
No known key found for this signature in database
GPG Key ID: 5EAC28EA3F980CCF
9 changed files with 105 additions and 109 deletions

View File

@ -31,7 +31,6 @@ class AppListItem<T> extends ConsumerStatefulWidget {
final Widget? trailing;
final List<ActionItem> Function(BuildContext context)? buildPopupActions;
final Widget Function(BuildContext context)? itemBuilder;
final BorderRadius? borderRadius;
final Intent? tapIntent;
final Intent? doubleTapIntent;
final bool selected;
@ -46,7 +45,6 @@ class AppListItem<T> extends ConsumerStatefulWidget {
this.trailing,
this.buildPopupActions,
this.itemBuilder,
this.borderRadius,
this.tapIntent,
this.doubleTapIntent,
this.selected = false,
@ -82,7 +80,7 @@ class _AppListItemState<T> extends ConsumerState<AppListItem> {
item: widget.item,
child: InkWell(
focusNode: _focusNode,
borderRadius: widget.borderRadius ?? BorderRadius.circular(48),
borderRadius: BorderRadius.circular(16),
onSecondaryTapDown: buildPopupActions == null
? null
: (details) {
@ -133,9 +131,10 @@ class _AppListItemState<T> extends ConsumerState<AppListItem> {
? SystemMouseCursors.click
: null,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(48)),
borderRadius: BorderRadius.circular(16)),
selectedTileColor: colorScheme.secondaryContainer,
selectedColor: colorScheme.onSecondaryContainer,
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
selected: widget.selected,
leading: widget.leading,
title: subtitle == null

View File

@ -331,15 +331,18 @@ class _FidoUnlockedPageState extends ConsumerState<_FidoUnlockedPage> {
}),
}
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: fingerprints
.map((fp) => _FingerprintListItem(
fp,
expanded: expanded,
selected: fp == _selected,
))
.toList()),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: fingerprints
.map((fp) => _FingerprintListItem(
fp,
expanded: expanded,
selected: fp == _selected,
))
.toList()),
),
);
},
),

View File

@ -426,9 +426,7 @@ class _FidoUnlockedPageState extends ConsumerState<_FidoUnlockedPage> {
setState(() {});
},
),
if (searchController.text.isEmpty &&
!searchFocus.hasFocus &&
showLayoutOptions)
if (searchController.text.isEmpty && showLayoutOptions)
...FlexLayout.values.map(
(e) => MouseRegion(
onEnter: (event) {
@ -533,24 +531,29 @@ class _FidoUnlockedPageState extends ConsumerState<_FidoUnlockedPage> {
child: Consumer(
builder: (context, ref, child) {
final layout = ref.watch(passkeysLayoutProvider);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (filteredCredentials.isEmpty)
Center(
child: Text(l10n.s_no_passkeys),
),
FlexBox<FidoCredential>(
items: filteredCredentials,
itemBuilder: (cred) => _CredentialListItem(
cred,
expanded: expanded,
selected: _selected == cred,
),
layout: layout,
getItemsPerRow: _getItemsPerRow,
)
],
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (filteredCredentials.isEmpty)
Center(
child: Text(l10n.s_no_passkeys),
),
FlexBox<FidoCredential>(
items: filteredCredentials,
itemBuilder: (cred) => _CredentialListItem(
cred,
expanded: expanded,
selected: _selected == cred,
),
layout: layout,
spacing: layout == FlexLayout.grid ? 4.0 : null,
runSpacing: layout == FlexLayout.grid ? 4.0 : null,
getItemsPerRow: _getItemsPerRow,
)
],
),
);
},
),

View File

@ -60,57 +60,45 @@ class AccountList extends ConsumerWidget {
return FocusTraversalGroup(
policy: WidgetOrderTraversalPolicy(),
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
padding: const EdgeInsets.only(top: 8.0, left: 16, right: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (pinnedCreds.isNotEmpty) ...[
Padding(
padding: const EdgeInsets.only(left: 16, bottom: 8),
child: Text(l10n.s_pinned, style: labelStyle),
),
Padding(
padding: pinnedLayout == FlexLayout.grid
? const EdgeInsets.only(left: 16.0, right: 16)
: const EdgeInsets.all(0),
child: FlexBox<OathPair>(
items: pinnedCreds.toList(),
itemBuilder: (value) => AccountView(
value.credential,
expanded: expanded,
selected: value.credential == selected,
large: pinnedLayout == FlexLayout.grid,
),
layout: pinnedLayout,
runSpacing: 8.0,
),
),
],
if (pinnedCreds.isNotEmpty && creds.isNotEmpty) ...[
const SizedBox(height: 24),
Padding(
padding: const EdgeInsets.only(left: 16, bottom: 8),
child: Text(
l10n.s_accounts,
style: labelStyle,
),
),
],
Padding(
padding: normalLayout == FlexLayout.grid
? const EdgeInsets.only(left: 16.0, right: 16)
: const EdgeInsets.all(0),
child: FlexBox<OathPair>(
items: creds.toList(),
Text(l10n.s_pinned, style: labelStyle),
const SizedBox(height: 8),
FlexBox<OathPair>(
items: pinnedCreds.toList(),
itemBuilder: (value) => AccountView(
value.credential,
expanded: expanded,
selected: value.credential == selected,
large: normalLayout == FlexLayout.grid,
large: pinnedLayout == FlexLayout.grid,
),
layout: normalLayout,
runSpacing: 8.0,
spacing: pinnedLayout == FlexLayout.grid ? 4.0 : null,
runSpacing: pinnedLayout == FlexLayout.grid ? 4.0 : null,
layout: pinnedLayout,
),
],
if (pinnedCreds.isNotEmpty && creds.isNotEmpty) ...[
const SizedBox(height: 24),
Text(
l10n.s_accounts,
style: labelStyle,
),
const SizedBox(height: 8),
],
FlexBox<OathPair>(
items: creds.toList(),
itemBuilder: (value) => AccountView(
value.credential,
expanded: expanded,
selected: value.credential == selected,
large: normalLayout == FlexLayout.grid,
),
spacing: normalLayout == FlexLayout.grid ? 4.0 : null,
runSpacing: normalLayout == FlexLayout.grid ? 4.0 : null,
layout: normalLayout,
),
],
),

View File

@ -120,7 +120,6 @@ class _AccountViewState extends ConsumerState<AccountView> {
? CopyIntent<OathCredential>(credential)
: null,
buildPopupActions: (_) => helper.buildActions(),
borderRadius: widget.large ? BorderRadius.circular(16) : null,
itemBuilder: widget.large
? (context) {
return ListTile(

View File

@ -452,8 +452,7 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
setState(() {});
},
),
if (searchController.text.isEmpty &&
!searchFocus.hasFocus) ...[
if (searchController.text.isEmpty) ...[
if (width >= 450)
...availableLayouts.map(
(e) => MouseRegion(

View File

@ -180,13 +180,16 @@ class _OtpScreenState extends ConsumerState<OtpScreen> {
return null;
}),
},
child: Column(children: [
...otpState.slots.map((e) => _SlotListItem(
e,
expanded: expanded,
selected: e == selected,
))
]),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(children: [
...otpState.slots.map((e) => _SlotListItem(
e,
expanded: expanded,
selected: e == selected,
))
]),
),
);
},
),

View File

@ -200,25 +200,28 @@ class _PivScreenState extends ConsumerState<PivScreen> {
return null;
}),
},
child: Column(
children: [
...normalSlots.map(
(e) => _CertificateListItem(
pivState,
e,
expanded: expanded,
selected: e == selected,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
children: [
...normalSlots.map(
(e) => _CertificateListItem(
pivState,
e,
expanded: expanded,
selected: e == selected,
),
),
),
...shownRetiredSlots.map(
(e) => _CertificateListItem(
pivState,
e,
expanded: expanded,
selected: e == selected,
),
)
],
...shownRetiredSlots.map(
(e) => _CertificateListItem(
pivState,
e,
expanded: expanded,
selected: e == selected,
),
)
],
),
),
);
},

View File

@ -21,6 +21,7 @@ class FlexBox<T> extends StatelessWidget {
final Widget Function(T value) itemBuilder;
final int Function(double width)? getItemsPerRow;
final FlexLayout layout;
final double? spacing;
final double? runSpacing;
const FlexBox({
super.key,
@ -28,7 +29,8 @@ class FlexBox<T> extends StatelessWidget {
required this.itemBuilder,
this.getItemsPerRow,
this.layout = FlexLayout.list,
this.runSpacing,
this.spacing = 0.0,
this.runSpacing = 0.0,
});
int _getItemsPerRow(double width) {
@ -92,10 +94,7 @@ class FlexBox<T> extends StatelessWidget {
return Column(
children: [
for (final c in chunks) ...[
if (chunks.indexOf(c) > 0 &&
layout == FlexLayout.grid &&
runSpacing != null)
SizedBox(height: runSpacing),
if (chunks.indexOf(c) > 0) SizedBox(height: runSpacing),
Row(
children: [
for (final entry in c) ...[
@ -103,7 +102,7 @@ class FlexBox<T> extends StatelessWidget {
child: itemBuilder(entry),
),
if (itemsPerRow != 1 && c.indexOf(entry) != c.length - 1)
const SizedBox(width: 8),
SizedBox(width: spacing),
],
if (c.length < itemsPerRow) ...[
// Prevents resizing when an items is removed