fix(mobile): people collection page layout broken in landscape (#19004)

fix(mobile): people collection page layout broken on landscape
This commit is contained in:
JobiJoba 2025-06-09 09:49:13 +07:00 committed by GitHub
parent 48e16f0a5a
commit e376366b7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,80 +60,84 @@ class PeopleCollectionPage extends HookConsumerWidget {
), ),
], ],
), ),
body: people.when( body: SafeArea(
data: (people) { child: people.when(
if (search.value != null) { data: (people) {
people = people.where((person) { if (search.value != null) {
return person.name people = people.where((person) {
.toLowerCase() return person.name
.contains(search.value!.toLowerCase()); .toLowerCase()
}).toList(); .contains(search.value!.toLowerCase());
} }).toList();
return GridView.builder( }
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( return GridView.builder(
crossAxisCount: isTablet ? 6 : 3, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
childAspectRatio: 0.85, crossAxisCount: isTablet ? 6 : 3,
mainAxisSpacing: isPortrait && isTablet ? 36 : 0, childAspectRatio: 0.85,
), mainAxisSpacing: isPortrait && isTablet ? 36 : 0,
padding: const EdgeInsets.symmetric(vertical: 32), ),
itemCount: people.length, padding: const EdgeInsets.symmetric(vertical: 32),
itemBuilder: (context, index) { itemCount: people.length,
final person = people[index]; itemBuilder: (context, index) {
final person = people[index];
return Column( return Column(
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
context.pushRoute( context.pushRoute(
PersonResultRoute( PersonResultRoute(
personId: person.id, personId: person.id,
personName: person.name, personName: person.name,
), ),
); );
}, },
child: Material( child: Material(
shape: const CircleBorder(side: BorderSide.none), shape: const CircleBorder(side: BorderSide.none),
elevation: 3, elevation: 3,
child: CircleAvatar( child: CircleAvatar(
maxRadius: isTablet ? 120 / 2 : 96 / 2, maxRadius: isTablet ? 120 / 2 : 96 / 2,
backgroundImage: NetworkImage( backgroundImage: NetworkImage(
getFaceThumbnailUrl(person.id), getFaceThumbnailUrl(person.id),
headers: headers, headers: headers,
),
), ),
), ),
), ),
), const SizedBox(height: 12),
const SizedBox(height: 12), GestureDetector(
GestureDetector( onTap: () =>
onTap: () => showNameEditModel(person.id, person.name), showNameEditModel(person.id, person.name),
child: person.name.isEmpty child: person.name.isEmpty
? Text( ? Text(
'add_a_name'.tr(), 'add_a_name'.tr(),
style: context.textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w500,
color: context.colorScheme.primary,
),
)
: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
),
child: Text(
person.name,
overflow: TextOverflow.ellipsis,
style: context.textTheme.titleSmall?.copyWith( style: context.textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: context.colorScheme.primary,
),
)
: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
),
child: Text(
person.name,
overflow: TextOverflow.ellipsis,
style:
context.textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w500,
),
), ),
), ),
), ),
), ],
], );
); },
}, );
); },
}, error: (error, stack) => const Text("error"),
error: (error, stack) => const Text("error"), loading: () => const Center(child: CircularProgressIndicator()),
loading: () => const Center(child: CircularProgressIndicator()), ),
), ),
); );
}, },