Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show local media #10

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .idea/libraries/Dart_Packages.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/libraries/Flutter_Plugins.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 18 additions & 9 deletions app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

<application
android:label="cloud_gallery"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:label="Cloud Gallery">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
Expand Down
7 changes: 7 additions & 0 deletions app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ PODS:
- AppAuth/Core (~> 1.6)
- GTMSessionFetcher/Core (< 4.0, >= 1.5)
- GTMSessionFetcher/Core (3.2.0)
- photo_manager (2.0.0):
- Flutter
- FlutterMacOS
- PromisesObjC (2.3.1)

DEPENDENCIES:
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- Flutter (from `Flutter`)
- google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`)
- photo_manager (from `.symlinks/plugins/photo_manager/ios`)

SPEC REPOS:
trunk:
Expand All @@ -60,6 +64,8 @@ EXTERNAL SOURCES:
:path: Flutter
google_sign_in_ios:
:path: ".symlinks/plugins/google_sign_in_ios/darwin"
photo_manager:
:path: ".symlinks/plugins/photo_manager/ios"

SPEC CHECKSUMS:
AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570
Expand All @@ -73,6 +79,7 @@ SPEC CHECKSUMS:
GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34
GTMAppAuth: 99fb010047ba3973b7026e45393f51f27ab965ae
GTMSessionFetcher: 41b9ef0b4c08a6db4b7eb51a21ae5183ec99a2c8
photo_manager: 4f6810b7dfc4feb03b461ac1a70dacf91fba7604
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4

PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796
Expand Down
4 changes: 4 additions & 0 deletions app/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Cloud Gallery would like to save photos to your gallery</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Cloud Gallery would like to access your gallery</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
Expand Down
95 changes: 84 additions & 11 deletions app/lib/ui/flow/main/main_screen.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,96 @@
import 'package:cloud_gallery/utils/extensions/context_extensions.dart';
import 'package:cloud_gallery/components/app_page.dart';
import 'package:data/services/local_media_service.dart';
import 'package:flutter/material.dart';
import 'package:style/text/app_text_style.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:photo_manager/photo_manager.dart';
import 'package:photo_manager_image_provider/photo_manager_image_provider.dart';
import 'package:style/animations/parallex_effect.dart';

class HomeScreen extends StatefulWidget {
class HomeScreen extends ConsumerStatefulWidget {
const HomeScreen({super.key});

@override
State<HomeScreen> createState() => _MainScreenState();
ConsumerState<HomeScreen> createState() => _MainScreenState();
}

class _MainScreenState extends State<HomeScreen> {
class _MainScreenState extends ConsumerState<HomeScreen> {
late LocalMediaService localMediaService;

@override
void initState() {
localMediaService = ref.read(localMediaServiceProvider);
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: context.colorScheme.surface,
body: Center(
child: Text('Home Screen',
style: AppTextStyles.subtitle2
.copyWith(color: context.colorScheme.textPrimary))),
return AppPage(
title: 'Cloud Gallery',
body: FutureBuilder(
future: localMediaService.getAssets(),
builder: (context, snapshot) {
final res = snapshot.data;
if (res is List<AssetEntity>) {
return GridView.builder(
addAutomaticKeepAlives: true,
padding: const EdgeInsets.all(16),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 16,
mainAxisSpacing: 16,
),
itemCount: res.length,
itemBuilder: (context, index) => res[index].type == AssetType.image?ImageItem(
imageProvider: AssetEntityImageProvider(
res[index],
thumbnailSize: const ThumbnailSize.square(200),
isOriginal: true,
thumbnailFormat: ThumbnailFormat.jpeg,
)
): const SizedBox(),
);
}
return const Center(child: CircularProgressIndicator());
},
),
);
}
}

class ImageItem extends StatefulWidget {
final ImageProvider imageProvider;

const ImageItem({super.key, required this.imageProvider});

@override
State<ImageItem> createState() => _ImageItemState();
}

class _ImageItemState extends State<ImageItem> {
final _backgroundImageKey = GlobalKey();

@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constraints) {
return ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Flow(
delegate: ParallaxFlowDelegate(
scrollable: Scrollable.of(context),
listItemContext: context,
backgroundImageKey: _backgroundImageKey,
),
children: [
Image(
key: _backgroundImageKey,
image: widget.imageProvider,
fit: BoxFit.cover,
width: constraints.maxWidth,
height: constraints.maxHeight * 1.5,
),
],
),
);
});
}
}
2 changes: 2 additions & 0 deletions app/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import Foundation

import firebase_core
import google_sign_in_ios
import photo_manager

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))
PhotoManagerPlugin.register(with: registry.registrar(forPlugin: "PhotoManagerPlugin"))
}
16 changes: 16 additions & 0 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.8.3"
photo_manager:
dependency: "direct main"
description:
name: photo_manager
sha256: "8cf79918f6de9843b394a1670fe1aec54ebcac852b4b4c9ef88211894547dc61"
url: "https://pub.dev"
source: hosted
version: "3.0.0-dev.5"
photo_manager_image_provider:
dependency: "direct main"
description:
name: photo_manager_image_provider
sha256: c187f60c3fdbe5630735d9a0bccbb071397ec03dcb1ba6085c29c8adece798a0
url: "https://pub.dev"
source: hosted
version: "2.1.0"
plugin_platform_interface:
dependency: transitive
description:
Expand Down
5 changes: 4 additions & 1 deletion app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ dependencies:
style:
path: ../style

# services
photo_manager: ^3.0.0-dev.5
photo_manager_image_provider: ^2.1.0

# UI
cupertino_icons: ^1.0.2

Expand All @@ -39,7 +43,6 @@ dependencies:
freezed: ^2.4.6
freezed_annotation: ^2.4.1


dev_dependencies:
flutter_test:
sdk: flutter
Expand Down
1 change: 1 addition & 0 deletions data/.flutter-plugins
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ google_sign_in=/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in-6.2
google_sign_in_android=/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/
google_sign_in_ios=/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/
google_sign_in_web=/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+2/
photo_manager=/Users/pratikcanopas/.pub-cache/hosted/pub.dev/photo_manager-3.0.0-dev.5/
2 changes: 1 addition & 1 deletion data/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"google_sign_in_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/","native_build":true,"dependencies":[]}],"macos":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"google_sign_in_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+2/","dependencies":[]}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]}],"date_created":"2024-01-23 10:35:50.290203","version":"3.16.7"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"photo_manager","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/photo_manager-3.0.0-dev.5/","native_build":true,"dependencies":[]}],"android":[{"name":"google_sign_in_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/","native_build":true,"dependencies":[]},{"name":"photo_manager","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/photo_manager-3.0.0-dev.5/","native_build":true,"dependencies":[]}],"macos":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"photo_manager","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/photo_manager-3.0.0-dev.5/","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"google_sign_in_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+2/","dependencies":[]}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]},{"name":"photo_manager","dependencies":[]}],"date_created":"2024-01-24 18:58:15.075183","version":"3.16.7"}
26 changes: 19 additions & 7 deletions data/lib/models/media/media.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'media.freezed.dart';

part 'media.g.dart';

enum AppMediaType { image, video }

enum AppMediaOrientation { landscape, portrait }

@freezed
class Media with _$Media {
const factory Media({
class AppMedia with _$AppMedia {
const factory AppMedia({
required String id,
required String name,
required String image,
required double size,
String? name,
required String path,
double? displayHeight,
double? displayWidth,
required AppMediaType type,
String? mimeType,
required DateTime createdTime,
DateTime? modifiedTime,
}) = _Media;
AppMediaOrientation? orientation,
required double? latitude,
required double? longitude,
@Default(false) bool isLocal,
}) = _AppMedia;

factory Media.fromJson(Map<String, dynamic> json) => _$MediaFromJson(json);
factory AppMedia.fromJson(Map<String, dynamic> json) =>
_$AppMediaFromJson(json);
}
Loading
Loading