mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
feat: Select last logged in user with dpad enabled
This commit is contained in:
parent
378f68be2d
commit
b2657f6408
1 changed files with 6 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:iconsax_plus/iconsax_plus.dart';
|
import 'package:iconsax_plus/iconsax_plus.dart';
|
||||||
import 'package:reorderable_grid/reorderable_grid.dart';
|
import 'package:reorderable_grid/reorderable_grid.dart';
|
||||||
|
|
@ -27,6 +28,8 @@ class LoginUserGrid extends ConsumerWidget {
|
||||||
|
|
||||||
final neededWidth = crossAxisCount * mainAxisExtent + (crossAxisCount - 1) * 24.0;
|
final neededWidth = crossAxisCount * mainAxisExtent + (crossAxisCount - 1) * 24.0;
|
||||||
|
|
||||||
|
final lastUsedAccount = users.sorted((a, b) => a.lastUsed.compareTo(b.lastUsed)).last;
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: neededWidth,
|
width: neededWidth,
|
||||||
child: ReorderableGridView.builder(
|
child: ReorderableGridView.builder(
|
||||||
|
|
@ -48,6 +51,9 @@ class LoginUserGrid extends ConsumerWidget {
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: 1.0,
|
aspectRatio: 1.0,
|
||||||
child: FocusButton(
|
child: FocusButton(
|
||||||
|
autoFocus: AdaptiveLayout.inputDeviceOf(context) == InputDevice.dPad
|
||||||
|
? user.sameIdentity(lastUsedAccount)
|
||||||
|
: false,
|
||||||
onTap: () => editMode ? onLongPress?.call(user) : onPressed?.call(user),
|
onTap: () => editMode ? onLongPress?.call(user) : onPressed?.call(user),
|
||||||
onLongPress: switch (AdaptiveLayout.inputDeviceOf(context)) {
|
onLongPress: switch (AdaptiveLayout.inputDeviceOf(context)) {
|
||||||
InputDevice.dPad || InputDevice.pointer => () => onLongPress?.call(user),
|
InputDevice.dPad || InputDevice.pointer => () => onLongPress?.call(user),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue