Skip to content

Bridge private @State and @Environment by name - #757

Open
Ceylo wants to merge 1 commit into
skiptools:mainfrom
Ceylo:feature/private-state-by-name
Open

Ceylo wants to merge 1 commit into
skiptools:mainfrom
Ceylo:feature/private-state-by-name

Conversation

@Ceylo

@Ceylo Ceylo commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Reopened from skiptools/skipstone#316, since skipstone moved into this repo.

2nd part of skiptools/skip-fuse-ui#165

For a private property, this PR changes the Swift accessor's receiver:

func Java_initState_count() -> SkipUI.StateSupport {
    return (Java_bridgedProperty(self, "_count") as any BridgedStateProperty<SkipUI.StateSupport>).Java_initStateSupport()
}

SkipSwiftUI finds the wrapper by its label with Mirror. Views without private properties generate exactly what they did before.


Skip Pull Request Checklist:

  • REQUIRED: I have signed the Contributor Agreement
  • REQUIRED: I have tested my change locally with swift test
  • OPTIONAL: I have tested my change on an iOS simulator or device (not applicable: the generated bridge code only compiles for Android)
  • OPTIONAL: I have tested my change on an Android emulator or device

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

Tested on FurAffinityApp on an API 37 emulator: 37 views with private state, settings persist across a restart, feed and detail screens work.

Generated `_Bridge.swift` code cannot write `$name` for a `private` or
`fileprivate` state or environment property, so it now reads such a wrapper
through `Java_bridgedProperty(self, "_name")`. The Kotlin side and the code
for every other property are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
return [functionDeclaration]
}

private func swiftUIStateReceiver(_ name: String, boxName: String, supportTypeName: String, modifiers: Modifiers) -> String {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is used for @State but also for @AppStorage, @GestureState and @FocusState

Ceylo added a commit to Ceylo/skip-fuse-ui that referenced this pull request Nov 11, 2026
skipstone moved into skiptools/skip, so #316 was reopened there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ceylo added a commit to Ceylo/skip-fuse-ui that referenced this pull request Nov 11, 2026
Needs a skip release that bridges a private @State or @Environment
(skiptools/skip#757).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Ceylo
Ceylo marked this pull request as ready for review November 11, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant