mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-22 00:12:09 +03:00
Change passkeys gridview breakpoints
This commit is contained in:
parent
574e63e147
commit
3b8e4571b6
@ -589,6 +589,7 @@ class _FidoUnlockedPageState extends ConsumerState<_FidoUnlockedPage> {
|
||||
selected: _selected == cred,
|
||||
),
|
||||
layout: layout,
|
||||
getItemsPerRow: _getItemsPerRow,
|
||||
)
|
||||
],
|
||||
);
|
||||
@ -600,6 +601,36 @@ class _FidoUnlockedPageState extends ConsumerState<_FidoUnlockedPage> {
|
||||
);
|
||||
}
|
||||
|
||||
int _getItemsPerRow(double width) {
|
||||
int itemsPerRow = 1;
|
||||
if (width <= 600) {
|
||||
// single column
|
||||
itemsPerRow = 1;
|
||||
} else if (width <= 900) {
|
||||
// 2 column
|
||||
itemsPerRow = 2;
|
||||
} else if (width < 1300) {
|
||||
// 3 column
|
||||
itemsPerRow = 3;
|
||||
} else if (width < 1500) {
|
||||
// 4 column
|
||||
itemsPerRow = 4;
|
||||
} else if (width < 1700) {
|
||||
// 5 column
|
||||
itemsPerRow = 5;
|
||||
} else if (width < 1900) {
|
||||
// 6 column
|
||||
itemsPerRow = 6;
|
||||
} else if (width < 2100) {
|
||||
// 7 column
|
||||
itemsPerRow = 7;
|
||||
} else {
|
||||
// 8 column
|
||||
itemsPerRow = 8;
|
||||
}
|
||||
return itemsPerRow;
|
||||
}
|
||||
|
||||
Widget _buildLoadingPage(BuildContext context) => AppPage(
|
||||
title: AppLocalizations.of(context)!.s_passkeys,
|
||||
capabilities: const [Capability.fido2],
|
||||
|
@ -5,17 +5,19 @@ enum FlexLayout { grid, list }
|
||||
class FlexBox<T> extends StatelessWidget {
|
||||
final List<T> items;
|
||||
final Widget Function(T value) itemBuilder;
|
||||
final int Function(double width)? getItemsPerRow;
|
||||
final FlexLayout layout;
|
||||
final double? runSpacing;
|
||||
const FlexBox({
|
||||
super.key,
|
||||
required this.items,
|
||||
required this.itemBuilder,
|
||||
this.getItemsPerRow,
|
||||
this.layout = FlexLayout.list,
|
||||
this.runSpacing,
|
||||
});
|
||||
|
||||
int getItemsPerRow(double width) {
|
||||
int _getItemsPerRow(double width) {
|
||||
int itemsPerRow = 1;
|
||||
if (layout == FlexLayout.grid) {
|
||||
if (width <= 420) {
|
||||
@ -34,10 +36,13 @@ class FlexBox<T> extends StatelessWidget {
|
||||
// 5 column
|
||||
itemsPerRow = 5;
|
||||
} else if (width < 1800) {
|
||||
// 6 column
|
||||
itemsPerRow = 6;
|
||||
} else if (width < 2000) {
|
||||
// 7 column
|
||||
itemsPerRow = 7;
|
||||
} else {
|
||||
// 8 column
|
||||
itemsPerRow = 8;
|
||||
}
|
||||
}
|
||||
@ -65,7 +70,9 @@ class FlexBox<T> extends StatelessWidget {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final width = constraints.maxWidth;
|
||||
final itemsPerRow = getItemsPerRow(width);
|
||||
final itemsPerRow = layout == FlexLayout.grid
|
||||
? getItemsPerRow?.call(width) ?? _getItemsPerRow(width)
|
||||
: 1;
|
||||
final chunks = getChunks(itemsPerRow);
|
||||
|
||||
return Column(
|
||||
|
Loading…
Reference in New Issue
Block a user