feat: full local assets / album sync
This commit is contained in:
@@ -13,7 +13,7 @@ typedef RenderListAssetProvider = FutureOr<List<Asset>> Function({
|
||||
int? limit,
|
||||
});
|
||||
|
||||
class ImmichAssetGridCubit extends Cubit<RenderList> {
|
||||
class AssetGridCubit extends Cubit<RenderList> {
|
||||
final Stream<RenderList> _renderStream;
|
||||
final RenderListAssetProvider _assetProvider;
|
||||
late final StreamSubscription _renderListSubscription;
|
||||
@@ -24,7 +24,7 @@ class ImmichAssetGridCubit extends Cubit<RenderList> {
|
||||
/// assets cache loaded from DB with offset [_bufOffset]
|
||||
List<Asset> _buf = [];
|
||||
|
||||
ImmichAssetGridCubit({
|
||||
AssetGridCubit({
|
||||
required Stream<RenderList> renderStream,
|
||||
required RenderListAssetProvider assetProvider,
|
||||
}) : _renderStream = renderStream,
|
||||
|
||||
@@ -6,14 +6,13 @@ import 'package:immich_mobile/domain/models/render_list_element.model.dart';
|
||||
import 'package:immich_mobile/presentation/components/grid/draggable_scrollbar.dart';
|
||||
import 'package:immich_mobile/presentation/components/grid/immich_asset_grid.state.dart';
|
||||
import 'package:immich_mobile/presentation/components/image/immich_image.widget.dart';
|
||||
import 'package:immich_mobile/presentation/components/image/immich_thumbnail.widget.dart';
|
||||
import 'package:immich_mobile/utils/extensions/async_snapshot.extension.dart';
|
||||
import 'package:immich_mobile/utils/extensions/build_context.extension.dart';
|
||||
import 'package:immich_mobile/utils/extensions/color.extension.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
|
||||
part 'immich_asset_grid_header.widget.dart';
|
||||
part 'immich_grid_asset_placeholder.widget.dart';
|
||||
|
||||
class ImAssetGrid extends StatefulWidget {
|
||||
const ImAssetGrid({super.key});
|
||||
@@ -56,8 +55,7 @@ class _ImAssetGridState extends State<ImAssetGrid> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
BlocBuilder<ImmichAssetGridCubit, RenderList>(
|
||||
Widget build(BuildContext context) => BlocBuilder<AssetGridCubit, RenderList>(
|
||||
builder: (_, renderList) {
|
||||
final elements = renderList.elements;
|
||||
final grid = FlutterListView(
|
||||
@@ -72,7 +70,7 @@ class _ImAssetGridState extends State<ImAssetGrid> {
|
||||
_MonthHeader(text: section.header),
|
||||
RenderListDayHeaderElement() => Text(section.header),
|
||||
RenderListAssetElement() => FutureBuilder(
|
||||
future: context.read<ImmichAssetGridCubit>().loadAssets(
|
||||
future: context.read<AssetGridCubit>().loadAssets(
|
||||
section.assetOffset,
|
||||
section.assetCount,
|
||||
),
|
||||
@@ -83,6 +81,7 @@ class _ImAssetGridState extends State<ImAssetGrid> {
|
||||
shrinkWrap: true,
|
||||
addAutomaticKeepAlives: false,
|
||||
cacheExtent: 100,
|
||||
padding: const EdgeInsets.all(0),
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4,
|
||||
@@ -97,8 +96,8 @@ class _ImAssetGridState extends State<ImAssetGrid> {
|
||||
dimension: 200,
|
||||
// Show Placeholder when drag scrolled
|
||||
child: asset == null || _isDragScrolling
|
||||
? const _ImImagePlaceholder()
|
||||
: ImImage(asset),
|
||||
? const ImImagePlaceholder()
|
||||
: ImThumbnail(asset),
|
||||
);
|
||||
},
|
||||
itemCount: section.assetCount,
|
||||
|
||||
@@ -9,7 +9,12 @@ class _HeaderText extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 32.0, left: 16.0, right: 24.0),
|
||||
padding: const EdgeInsets.only(
|
||||
top: 32.0,
|
||||
left: 16.0,
|
||||
right: 24.0,
|
||||
bottom: 16.0,
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
part of 'immich_asset_grid.widget.dart';
|
||||
|
||||
class _ImImagePlaceholder extends StatelessWidget {
|
||||
const _ImImagePlaceholder();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var gradientColors = [
|
||||
context.colorScheme.surfaceContainer,
|
||||
context.colorScheme.surfaceContainer.darken(amount: .1),
|
||||
];
|
||||
|
||||
return Container(
|
||||
width: 200,
|
||||
height: 200,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: gradientColors,
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user