mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
Some checks failed
CLI Build / CLI Publish (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Docker / pre-job (push) Has been cancelled
Docs build / pre-job (push) Has been cancelled
Zizmor / Zizmor (push) Has been cancelled
Static Code Analysis / pre-job (push) Has been cancelled
Test / pre-job (push) Has been cancelled
Test / ShellCheck (push) Has been cancelled
Test / OpenAPI Clients (push) Has been cancelled
Test / SQL Schema Checks (push) Has been cancelled
CLI Build / Docker (push) Has been cancelled
Docker / Re-Tag ML (push) Has been cancelled
Docker / Re-Tag Server (push) Has been cancelled
Docker / Build and Push ML (push) Has been cancelled
Docker / Build and Push Server (push) Has been cancelled
Docker / Mirror to Docker Hub (push) Has been cancelled
Docker / Docker Build & Push Server Success (push) Has been cancelled
Docker / Docker Build & Push ML Success (push) Has been cancelled
Docs build / Docs Build (push) Has been cancelled
Static Code Analysis / Run Dart Code Analysis (push) Has been cancelled
Test / Scripts unit tests (push) Has been cancelled
Test / Test & Lint Server (push) Has been cancelled
Test / Unit Test CLI (push) Has been cancelled
Test / Unit Test CLI (Windows) (push) Has been cancelled
Test / Lint Web (push) Has been cancelled
Test / Test Web (push) Has been cancelled
Test / Test i18n (push) Has been cancelled
Test / End-to-End Lint (push) Has been cancelled
Test / Medium Tests (Server) (push) Has been cancelled
Test / End-to-End Tests (Server & CLI) (push) Has been cancelled
Test / End-to-End Tests (Web) (push) Has been cancelled
Test / End-to-End Tests Success (push) Has been cancelled
Test / Unit Test Mobile (push) Has been cancelled
Test / Unit Test ML (push) Has been cancelled
Test / .github Files Formatting (push) Has been cancelled
The lints are regrouped and sorted. Also, added the following new lints: - unnecessary_ignore - parameter_assignments - avoid_unused_constructor_parameters - tighten_type_of_initializing_formals - only_throw_errors - deprecated_consistency - unnecessary_statements Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
142 lines
5.7 KiB
Dart
142 lines
5.7 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:auto_route/auto_route.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/domain/models/person.model.dart';
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|
import 'package:immich_mobile/extensions/string_extensions.dart';
|
|
import 'package:immich_mobile/generated/translations.g.dart';
|
|
import 'package:immich_mobile/presentation/widgets/images/remote_image_provider.dart';
|
|
import 'package:immich_mobile/providers/infrastructure/people.provider.dart';
|
|
import 'package:immich_mobile/routing/router.dart';
|
|
import 'package:immich_mobile/utils/image_url_builder.dart';
|
|
import 'package:immich_mobile/utils/people.utils.dart';
|
|
import 'package:immich_mobile/widgets/common/search_field.dart';
|
|
|
|
@RoutePage()
|
|
class DriftPeopleCollectionPage extends ConsumerStatefulWidget {
|
|
const DriftPeopleCollectionPage({super.key});
|
|
|
|
@override
|
|
ConsumerState<DriftPeopleCollectionPage> createState() => _DriftPeopleCollectionPageState();
|
|
}
|
|
|
|
class _DriftPeopleCollectionPageState extends ConsumerState<DriftPeopleCollectionPage> {
|
|
final FocusNode _formFocus = FocusNode();
|
|
String? _search;
|
|
|
|
@override
|
|
void dispose() {
|
|
_formFocus.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final people = ref.watch(getAllPeopleProvider);
|
|
|
|
return LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
final isTablet = constraints.maxWidth > 600;
|
|
final isPortrait = context.orientation == Orientation.portrait;
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
automaticallyImplyLeading: _search == null,
|
|
title: _search != null
|
|
? SearchField(
|
|
focusNode: _formFocus,
|
|
onTapOutside: (_) => _formFocus.unfocus(),
|
|
onChanged: (value) => setState(() => _search = value),
|
|
filled: true,
|
|
hintText: context.t.filter_people,
|
|
autofocus: true,
|
|
)
|
|
: Text(context.t.people),
|
|
actions: [
|
|
IconButton(
|
|
icon: Icon(_search != null ? Icons.close : Icons.search),
|
|
onPressed: () {
|
|
setState(() => _search = _search == null ? '' : null);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
body: SafeArea(
|
|
child: people.when(
|
|
data: (people) {
|
|
final List<Person> filtered;
|
|
if (_search != null) {
|
|
filtered = people.where((person) {
|
|
return person.name.toLowerCase().removeDiacritics().contains(
|
|
_search!.toLowerCase().removeDiacritics(),
|
|
);
|
|
}).toList();
|
|
} else {
|
|
filtered = people;
|
|
}
|
|
return GridView.builder(
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: isTablet ? 6 : 3,
|
|
childAspectRatio: 0.85,
|
|
mainAxisSpacing: isPortrait && isTablet ? 36 : 0,
|
|
),
|
|
padding: const EdgeInsets.symmetric(vertical: 32),
|
|
itemCount: filtered.length,
|
|
itemBuilder: (context, index) {
|
|
final person = filtered[index];
|
|
|
|
return Column(
|
|
key: ValueKey(person.id),
|
|
children: [
|
|
GestureDetector(
|
|
onTap: () {
|
|
unawaited(context.pushRoute(DriftPersonRoute(person: person)));
|
|
},
|
|
child: Material(
|
|
shape: const CircleBorder(side: BorderSide.none),
|
|
elevation: 3,
|
|
child: CircleAvatar(
|
|
key: ValueKey(person.id),
|
|
maxRadius: isTablet ? 100 / 2 : 96 / 2,
|
|
backgroundImage: RemoteImageProvider(
|
|
url: getFaceThumbnailUrl(person.id, updatedAt: person.updatedAt),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
GestureDetector(
|
|
onTap: () => showNameEditModal(context, person),
|
|
child: person.name.isEmpty
|
|
? Text(
|
|
context.t.add_a_name,
|
|
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(fontWeight: FontWeight.w500),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
},
|
|
error: (error, stack) => const Text("error"),
|
|
loading: () => const Center(child: CircularProgressIndicator()),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|