ryanmcgrath / cacao

Rust bindings for AppKit (macOS) and UIKit (iOS/tvOS). Experimental, but working!
MIT License
1.8k stars 65 forks source link

Path to support labels, text, images, etc in iOS #7

Open jkelleyrtp opened 3 years ago

jkelleyrtp commented 3 years ago

I tried to add labels/text input for the iOS example and ran into a bunch of feature flags.

Is there a way to get labels/text wired up for iOS?

If not, can you give some direction on how to add it via a PR? I understand some of the code patterns, but there's still some architecture (make an Architecture.md?) that I would need to dig into to understand how to enable it properly. Also, is there a obj-c spec you're working off of or just using your ios/macos dev experience to know which NS concepts to bridge over?

ryanmcgrath commented 3 years ago

Unfortunately the iOS demo is (for the moment) barebones, yeah - it was mostly done first to make sure I could even support the UIScene+Delegate APIs that modern iOS needs, which was tricky to figure out how to do.

The good news is that from here on out adapting things shouldn't be too bad. I'm guessing the feature flags you hit were the target_os = "macos" ones in lib.rs? If so, yeah - that's mostly just to gate things so the iOS demo compiled, and it acts as a marker for what's support across the two.

If you want to jump in, the text module is probably the most straightforward to make compatible with iOS. It'd really come down to two things needing to be done:

Images are also theoretically decent to start with, but there's a custom draw handler I added and the API for that is slightly different across OS's so I might want to revisit it. Not sure.

I think an architecture.md is a great idea - I'm in moreso docs writing mode right now anyway so it fits in. If I can find some time this afternoon I'll get it added.

ryanmcgrath commented 3 years ago

Oh, and:

Also, is there a obj-c spec you're working off of or just using your ios/macos dev experience to know which NS concepts to bridge over?

Ish, yeah. I've been aiming for somewhat of a "common" API between the two OS's for two reasons:

I'd say that in general I try to err towards the iOS-style methods, since I think people are more familiar with those.

tl;dr yeah, a lot of it is my personal experience with ios/macos/tvos experience, but I'm pretty open to whatever. If it's helpful I suppose I could put together a channel somewhere for more discussion on this?

ryanmcgrath commented 3 years ago

I threw together a basic Architecture document - not perfect by any means, but it walks (or stumbles) through the View<T> type to kind of explain how things are typically set up. Can try to find time to flesh it out more.

lemarier commented 3 years ago

I could put together a channel somewhere for more discussion on this?

I would be interested to join! We are looking to build @tauri-apps for iOS/tvOS and maybe migrate our wry macOS implementation.

btw; amazing work!

ryanmcgrath commented 3 years ago

Cool, I can look at setting something up today.

Tauri apps might be hard on tvOS, if I'm understanding (at a glance) what you want to do, as no WebView is supported there. It's by far the least explored platform for Cacao though, so plenty of time to dig further anyway.

ryanmcgrath commented 1 year ago

FWIW, #48 adds image support for iOS. I would be curious what "core controls" people would need/want supported on iOS so that shoring up that side of things could happen.

(I know this issue is old, so apologies for raising a zombie here)

ryanmcgrath commented 12 months ago

(#48 has been merged)