feat/capacitor-mobile-app-poc
Zack Pollard 2024-05-21 12:42:12 +01:00
parent b50225327d
commit e503b92d79
8 changed files with 67 additions and 3 deletions

View File

@ -9,7 +9,8 @@ android {
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies { dependencies {
implementation project(':capacitor-community-media')
implementation project(':capacitor-filesystem')
} }

View File

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"

View File

@ -1,3 +1,9 @@
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN // DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
include ':capacitor-android' include ':capacitor-android'
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
include ':capacitor-community-media'
project(':capacitor-community-media').projectDir = new File('../node_modules/@capacitor-community/media/android')
include ':capacitor-filesystem'
project(':capacitor-filesystem').projectDir = new File('../node_modules/@capacitor/filesystem/android')

View File

@ -12,7 +12,14 @@ const config: CapacitorConfig = {
cleartext: true, cleartext: true,
allowNavigation: ['http://192.168.10.242:2283/api/*', 'http://localhost/*', 'https://localhost/*'], allowNavigation: ['http://192.168.10.242:2283/api/*', 'http://localhost/*', 'https://localhost/*'],
}, },
plugins: {}, plugins: {
CapacitorCookies: {
enabled: true,
},
CapacitorHttp: {
enabled: true,
},
},
}; };
export default config; export default config;

View File

@ -11,7 +11,8 @@ install! 'cocoapods', :disable_input_output_paths => true
def capacitor_pods def capacitor_pods
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCommunityMedia', :path => '../../node_modules/@capacitor-community/media'
pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem'
end end
target 'App' do target 'App' do

18
web/package-lock.json generated
View File

@ -9,8 +9,10 @@
"version": "1.105.1", "version": "1.105.1",
"license": "GNU Affero General Public License version 3", "license": "GNU Affero General Public License version 3",
"dependencies": { "dependencies": {
"@capacitor-community/media": "^6.0.0",
"@capacitor/android": "^6.0.0", "@capacitor/android": "^6.0.0",
"@capacitor/core": "^6.0.0", "@capacitor/core": "^6.0.0",
"@capacitor/filesystem": "^6.0.0",
"@capacitor/ios": "^6.0.0", "@capacitor/ios": "^6.0.0",
"@immich/sdk": "file:../open-api/typescript-sdk", "@immich/sdk": "file:../open-api/typescript-sdk",
"@mdi/js": "^7.4.47", "@mdi/js": "^7.4.47",
@ -455,6 +457,14 @@
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
"dev": true "dev": true
}, },
"node_modules/@capacitor-community/media": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@capacitor-community/media/-/media-6.0.0.tgz",
"integrity": "sha512-hROzyGI6pUv9FF86elePw/AqbWybrxgsY+f+83/erMBLhue3HkJaScWCZ7473UpdGKRgxfLEjsUN+Quwvy0NxA==",
"peerDependencies": {
"@capacitor/core": "^6.0.0"
}
},
"node_modules/@capacitor/android": { "node_modules/@capacitor/android": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/@capacitor/android/-/android-6.0.0.tgz", "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-6.0.0.tgz",
@ -594,6 +604,14 @@
"tslib": "^2.1.0" "tslib": "^2.1.0"
} }
}, },
"node_modules/@capacitor/filesystem": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@capacitor/filesystem/-/filesystem-6.0.0.tgz",
"integrity": "sha512-GnC4CBfky7fvG9zSV/aQnZaGs6ZJ90AaQorr53z81ArTCqcrSUeBMuCxWmvti9HrdXLhBavyA1UOjvRGObOFjg==",
"peerDependencies": {
"@capacitor/core": "^6.0.0"
}
},
"node_modules/@capacitor/ios": { "node_modules/@capacitor/ios": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/@capacitor/ios/-/ios-6.0.0.tgz", "resolved": "https://registry.npmjs.org/@capacitor/ios/-/ios-6.0.0.tgz",

View File

@ -61,8 +61,10 @@
}, },
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@capacitor-community/media": "^6.0.0",
"@capacitor/android": "^6.0.0", "@capacitor/android": "^6.0.0",
"@capacitor/core": "^6.0.0", "@capacitor/core": "^6.0.0",
"@capacitor/filesystem": "^6.0.0",
"@capacitor/ios": "^6.0.0", "@capacitor/ios": "^6.0.0",
"@immich/sdk": "file:../open-api/typescript-sdk", "@immich/sdk": "file:../open-api/typescript-sdk",
"@mdi/js": "^7.4.47", "@mdi/js": "^7.4.47",

View File

@ -24,6 +24,21 @@
import { mdiDotsVertical, mdiPlus } from '@mdi/js'; import { mdiDotsVertical, mdiPlus } from '@mdi/js';
import { user } from '$lib/stores/user.store'; import { user } from '$lib/stores/user.store';
import { Media, type MediaAlbum, type MediaAsset, type MediaResponse } from '@capacitor-community/media';
let albums: MediaAlbum[] = [];
const getAlbums = async () => {
const { albums: newAlbums } = await Media.getAlbums();
albums = newAlbums;
};
let cameraRoll: MediaAsset[] = [];
const getCameraRoll = async () => {
const { medias: newCameraRoll } = await Media.getMedias({albumIdentifier: 'camera'});
cameraRoll = newCameraRoll;
};
let { isViewing: showAssetViewer } = assetViewingStore; let { isViewing: showAssetViewer } = assetViewingStore;
let handleEscapeKey = false; let handleEscapeKey = false;
const assetStore = new AssetStore({ isArchived: false, withStacked: true, withPartners: true }); const assetStore = new AssetStore({ isArchived: false, withStacked: true, withPartners: true });
@ -91,6 +106,15 @@
{/if} {/if}
<UserPageLayout hideNavbar={$isMultiSelectState} showUploadButton scrollbar={false}> <UserPageLayout hideNavbar={$isMultiSelectState} showUploadButton scrollbar={false}>
<button on:click={getAlbums}>Get Albums</button>
{#if albums.length > 0}
<p>Albums: {albums.map(album => album.name).join(", ")}</p>
{/if}
<button on:click={getCameraRoll}>Get Camera Roll</button>
{#if cameraRoll.length > 0}
<p>Camera Roll: {cameraRoll.map(asset => asset.identifier)}</p>
{/if}
<AssetGrid <AssetGrid
{assetStore} {assetStore}
{assetInteractionStore} {assetInteractionStore}