Push to remote repo

This commit is contained in:
Alex Kim
2024-10-10 23:40:01 +11:00
parent ef7fbc985f
commit 8be1e2df0c
26 changed files with 266 additions and 47 deletions

View File

@@ -0,0 +1,2 @@
#Thu Oct 10 22:31:55 AEDT 2024
gradle.version=8.9

View File

@@ -0,0 +1,43 @@
apply plugin: 'com.android.library'
group = 'expo.modules.vlcplayer'
version = '0.6.0'
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
apply from: expoModulesCorePlugin
applyKotlinExpoModulesCorePlugin()
useCoreDependencies()
useExpoPublishing()
// If you want to use the managed Android SDK versions from expo-modules-core, set this to true.
// The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
// Most of the time, you may like to manage the Android SDK versions yourself.
def useManagedAndroidSdkVersions = false
if (useManagedAndroidSdkVersions) {
useDefaultAndroidSdkVersions()
} else {
buildscript {
// Simple helper that allows the root project to override versions declared by this library.
ext.safeExtGet = { prop, fallback ->
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
}
project.android {
compileSdkVersion safeExtGet("compileSdkVersion", 34)
defaultConfig {
minSdkVersion safeExtGet("minSdkVersion", 21)
targetSdkVersion safeExtGet("targetSdkVersion", 34)
}
}
}
android {
namespace "expo.modules.vlcplayer"
defaultConfig {
versionCode 1
versionName "0.6.0"
}
lintOptions {
abortOnError false
}
}

View File

@@ -0,0 +1,2 @@
<manifest>
</manifest>

View File

@@ -0,0 +1,47 @@
package expo.modules.vlcplayer
import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition
class VlcPlayerModule : Module() {
// Each module class must implement the definition function. The definition consists of components
// that describes the module's functionality and behavior.
// See https://docs.expo.dev/modules/module-api for more details about available components.
override fun definition() = ModuleDefinition {
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
// The module will be accessible from `requireNativeModule('VlcPlayer')` in JavaScript.
Name("VlcPlayer")
// Sets constant properties on the module. Can take a dictionary or a closure that returns a dictionary.
Constants(
"PI" to Math.PI
)
// Defines event names that the module can send to JavaScript.
Events("onChange")
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
Function("hello") {
"Hello world! 👋"
}
// Defines a JavaScript function that always returns a Promise and whose native code
// is by default dispatched on the different thread than the JavaScript runtime runs on.
AsyncFunction("setValueAsync") { value: String ->
// Send an event to JavaScript.
sendEvent("onChange", mapOf(
"value" to value
))
}
// Enables the module to be used as a native view. Definition components that are accepted as part of
// the view definition: Prop, Events.
View(VlcPlayerView::class) {
// Defines a setter for the `name` prop.
Prop("name") { view: VlcPlayerView, prop: String ->
println(prop)
}
}
}
}

View File

@@ -0,0 +1,7 @@
package expo.modules.vlcplayer
import android.content.Context
import expo.modules.kotlin.AppContext
import expo.modules.kotlin.views.ExpoView
class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context, appContext)

View File

@@ -0,0 +1,9 @@
{
"platforms": ["ios", "tvos", "android", "web"],
"ios": {
"modules": ["VlcPlayerModule"]
},
"android": {
"modules": ["expo.modules.vlcplayer.VlcPlayerModule"]
}
}

View File

@@ -0,0 +1,26 @@
import { NativeModulesProxy, EventEmitter, Subscription } from 'expo-modules-core';
// Import the native module. On web, it will be resolved to VlcPlayer.web.ts
// and on native platforms to VlcPlayer.ts
import VlcPlayerModule from './src/VlcPlayerModule';
import VlcPlayerView from './src/VlcPlayerView';
import { ChangeEventPayload, VlcPlayerViewProps } from './src/VlcPlayer.types';
// Get the native constant value.
export const PI = VlcPlayerModule.PI;
export function hello(): string {
return VlcPlayerModule.hello();
}
export async function setValueAsync(value: string) {
return await VlcPlayerModule.setValueAsync(value);
}
const emitter = new EventEmitter(VlcPlayerModule ?? NativeModulesProxy.VlcPlayer);
export function addChangeListener(listener: (event: ChangeEventPayload) => void): Subscription {
return emitter.addListener<ChangeEventPayload>('onChange', listener);
}
export { VlcPlayerView, VlcPlayerViewProps, ChangeEventPayload };

View File

@@ -0,0 +1,22 @@
Pod::Spec.new do |s|
s.name = 'VlcPlayer'
s.version = '1.0.0'
s.summary = 'A sample project summary'
s.description = 'A sample project description'
s.author = ''
s.homepage = 'https://docs.expo.dev/modules/'
s.platforms = { :ios => '13.4', :tvos => '13.4' }
s.source = { git: '' }
s.static_framework = true
s.dependency 'ExpoModulesCore'
s.dependency 'MobileVLCKit'
# Swift/Objective-C compatibility
s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES',
'SWIFT_COMPILATION_MODE' => 'wholemodule'
}
s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
end

View File

@@ -0,0 +1,44 @@
import ExpoModulesCore
public class VlcPlayerModule: Module {
// Each module class must implement the definition function. The definition consists of components
// that describes the module's functionality and behavior.
// See https://docs.expo.dev/modules/module-api for more details about available components.
public func definition() -> ModuleDefinition {
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
// The module will be accessible from `requireNativeModule('VlcPlayer')` in JavaScript.
Name("VlcPlayer")
// Sets constant properties on the module. Can take a dictionary or a closure that returns a dictionary.
Constants([
"PI": Double.pi
])
// Defines event names that the module can send to JavaScript.
Events("onChange")
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
Function("hello") {
return "Hello world! 👋"
}
// Defines a JavaScript function that always returns a Promise and whose native code
// is by default dispatched on the different thread than the JavaScript runtime runs on.
AsyncFunction("setValueAsync") { (value: String) in
// Send an event to JavaScript.
self.sendEvent("onChange", [
"value": value
])
}
// Enables the module to be used as a native view. Definition components that are accepted as part of the
// view definition: Prop, Events.
View(VlcPlayerView.self) {
// Defines a setter for the `name` prop.
Prop("name") { (view: VlcPlayerView, prop: String) in
print(prop)
}
}
}
}

View File

@@ -0,0 +1,7 @@
import ExpoModulesCore
// This view will be used as a native component. Make sure to inherit from `ExpoView`
// to apply the proper styling (e.g. border radius and shadows).
class VlcPlayerView: ExpoView {
}

View File

@@ -0,0 +1,7 @@
export type ChangeEventPayload = {
value: string;
};
export type VlcPlayerViewProps = {
name: string;
};

View File

@@ -0,0 +1,5 @@
import { requireNativeModule } from 'expo-modules-core';
// It loads the native module object from the JSI or falls back to
// the bridge module (from NativeModulesProxy) if the remote debugger is on.
export default requireNativeModule('VlcPlayer');

View File

@@ -0,0 +1,13 @@
import { EventEmitter } from 'expo-modules-core';
const emitter = new EventEmitter({} as any);
export default {
PI: Math.PI,
async setValueAsync(value: string): Promise<void> {
emitter.emit('onChange', { value });
},
hello() {
return 'Hello world! 👋';
},
};

View File

@@ -0,0 +1,11 @@
import { requireNativeViewManager } from 'expo-modules-core';
import * as React from 'react';
import { VlcPlayerViewProps } from './VlcPlayer.types';
const NativeView: React.ComponentType<VlcPlayerViewProps> =
requireNativeViewManager('VlcPlayer');
export default function VlcPlayerView(props: VlcPlayerViewProps) {
return <NativeView {...props} />;
}

View File

@@ -0,0 +1,11 @@
import * as React from 'react';
import { VlcPlayerViewProps } from './VlcPlayer.types';
export default function VlcPlayerView(props: VlcPlayerViewProps) {
return (
<div>
<span>{props.name}</span>
</div>
);
}