-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add image support for uikit feature backends #48
Changes from all commits
8b43d43
66e1f91
cf11a93
c58de62
9decae6
968843e
bab9e7d
caff6a1
4483b81
cf2cf5c
ba893c3
46b313b
78be15b
d80b38c
9f0d281
dcb24c2
3425f83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ use std::sync::RwLock; | |
use cacao::uikit::{App, AppDelegate, Scene, SceneConfig, SceneConnectionOptions, SceneSession, Window, WindowSceneDelegate}; | ||
|
||
use cacao::color::Color; | ||
use cacao::image::{Image, ImageView}; | ||
use cacao::layout::{Layout, LayoutConstraint}; | ||
use cacao::view::{View, ViewController, ViewDelegate}; | ||
|
||
|
@@ -19,7 +20,8 @@ impl AppDelegate for TestApp { | |
pub struct RootView { | ||
pub red: View, | ||
pub green: View, | ||
pub blue: View | ||
pub blue: View, | ||
pub image: ImageView | ||
} | ||
|
||
impl ViewDelegate for RootView { | ||
|
@@ -36,6 +38,11 @@ impl ViewDelegate for RootView { | |
self.blue.set_background_color(Color::SystemBlue); | ||
view.add_subview(&self.blue); | ||
|
||
let image_bytes = include_bytes!("../../test-data/favicon.ico"); | ||
self.image = ImageView::new(); | ||
self.image.set_image(&Image::with_data(image_bytes)); | ||
view.add_subview(&self.image); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha, I can write up some autolayout hell for this to make it look "nicer" once this is merged. I'd really like to get labels and listview support in, so it'd be cool to get a true "kitchen sink" iOS demo at some point here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. It'd be nice if it could be use similar to the other views of |
||
|
||
LayoutConstraint::activate(&[ | ||
self.red.top.constraint_equal_to(&view.top).offset(16.), | ||
self.red.leading.constraint_equal_to(&view.leading).offset(16.), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm back and forth on whether this one should disable
autolayout
- it's feature flagged for platforms that might not have that, but can still do frame-based layout. I think ifautolayout
is disabled it may also break the example at the moment, so I can PR this one after this is merged.