-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 51 additions & 2 deletions
53
packages/nitrogen/src/views/kotlin/KotlinHybridViewManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,57 @@ | ||
import type { SourceFile } from '../../syntax/SourceFile.js' | ||
import type { HybridObjectSpec } from '../../syntax/HybridObjectSpec.js' | ||
import { | ||
createViewComponentShadowNodeFiles, | ||
getViewComponentNames, | ||
} from '../ViewComponentShadowNode.js' | ||
import { createFileMetadataString } from '../../syntax/helpers.js' | ||
import { NitroConfig } from '../../config/NitroConfig.js' | ||
|
||
export function createKotlinHybridViewManager( | ||
_: HybridObjectSpec | ||
spec: HybridObjectSpec | ||
): SourceFile[] { | ||
return [] | ||
const cppFiles = createViewComponentShadowNodeFiles(spec) | ||
const javaNamespace = NitroConfig.getAndroidPackage('java/kotlin', 'views') | ||
const { manager } = getViewComponentNames(spec) | ||
|
||
const mmFile = ` | ||
${createFileMetadataString(`${manager}.kt`)} | ||
package ${javaNamespace} | ||
import android.view.View | ||
import com.facebook.react.fabric.StateWrapperImpl | ||
import com.facebook.react.uimanager.ReactStylesDiffMap | ||
import com.facebook.react.uimanager.SimpleViewManager | ||
import com.facebook.react.uimanager.StateWrapper | ||
import com.facebook.react.uimanager.ThemedReactContext | ||
class ${manager} extends SimpleViewManager<View> { | ||
override fun getName(): String { | ||
return "${spec.name}" | ||
} | ||
override fun createViewInstance(reactContext: ThemedReactContext): View { | ||
throw Error("Not yet implemented!") | ||
} | ||
override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any { | ||
val stateWrapperImpl = stateWrapper as? StateWrapperImpl ?: throw Error("StateWrapper uses a different implementation!") | ||
// TODO: Get props from stateWrapperImpl and update them in HybridView | ||
return super.updateState(view, props, stateWrapper) | ||
} | ||
} | ||
` | ||
|
||
return [ | ||
...cppFiles, | ||
{ | ||
content: mmFile, | ||
language: 'kotlin', | ||
name: `${manager}.kt`, | ||
platform: 'android', | ||
subdirectory: [...javaNamespace.split('.')], | ||
}, | ||
] | ||
} |
32 changes: 32 additions & 0 deletions
32
...-image/nitrogen/generated/android/kotlin/com/margelo/nitro/image/views/TestViewManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/// | ||
/// TestViewManager.kt | ||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. | ||
/// https://github.com/mrousavy/nitro | ||
/// Copyright © 2025 Marc Rousavy @ Margelo | ||
/// | ||
|
||
package com.margelo.nitro.image.views | ||
|
||
import android.view.View | ||
import com.facebook.react.fabric.StateWrapperImpl | ||
import com.facebook.react.uimanager.ReactStylesDiffMap | ||
import com.facebook.react.uimanager.SimpleViewManager | ||
import com.facebook.react.uimanager.StateWrapper | ||
import com.facebook.react.uimanager.ThemedReactContext | ||
|
||
class TestViewManager extends SimpleViewManager<View> { | ||
override fun getName(): String { | ||
return "TestView" | ||
} | ||
|
||
override fun createViewInstance(reactContext: ThemedReactContext): View { | ||
throw Error("Not yet implemented!") | ||
} | ||
|
||
override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any { | ||
val stateWrapperImpl = stateWrapper as? StateWrapperImpl ?: throw Error("StateWrapper uses a different implementation!") | ||
// TODO: Get props from stateWrapperImpl and update them in HybridView | ||
|
||
return super.updateState(view, props, stateWrapper) | ||
} | ||
} |