Updates from comments
This commit is contained in:
parent
b0b93468d8
commit
d0d99df147
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
|
@ -21,6 +21,18 @@ jobs:
|
||||||
with:
|
with:
|
||||||
command: fmt
|
command: fmt
|
||||||
args: -- --check
|
args: -- --check
|
||||||
|
test:
|
||||||
|
name: Check that examples build
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
- uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
build:
|
build:
|
||||||
name: Check that the code builds
|
name: Check that the code builds
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
@ -42,9 +54,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
override: true
|
override: true
|
||||||
- uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: test
|
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
|
|
11
Cargo.toml
11
Cargo.toml
|
@ -53,3 +53,14 @@ identifier = "com.cacao.ios-test"
|
||||||
category = "Developer Tool"
|
category = "Developer Tool"
|
||||||
short_description = "An example Cacao iOS app."
|
short_description = "An example Cacao iOS app."
|
||||||
long_description = "An example Cacao iOS app."
|
long_description = "An example Cacao iOS app."
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "webview_custom_protocol"
|
||||||
|
required-features = ["webview"]
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "browser"
|
||||||
|
required-features = ["webview"]
|
||||||
|
[[example]]
|
||||||
|
name = "ios-beta"
|
||||||
|
required-features = ["uikit", "autolayout"]
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
//! work with autolayout, and some basic ways to handle colors.
|
//! work with autolayout, and some basic ways to handle colors.
|
||||||
|
|
||||||
use cacao::notification_center::Dispatcher;
|
use cacao::notification_center::Dispatcher;
|
||||||
#[cfg(feature = "webview")]
|
|
||||||
use cacao::webview::{WebView, WebViewConfig, WebViewDelegate};
|
use cacao::webview::{WebView, WebViewConfig, WebViewDelegate};
|
||||||
|
|
||||||
use cacao::appkit::menu::{Menu, MenuItem};
|
use cacao::appkit::menu::{Menu, MenuItem};
|
||||||
|
@ -73,8 +72,6 @@ impl Dispatcher for BasicApp {
|
||||||
|
|
||||||
fn on_ui_message(&self, message: Self::Message) {
|
fn on_ui_message(&self, message: Self::Message) {
|
||||||
let window = self.window.delegate.as_ref().unwrap();
|
let window = self.window.delegate.as_ref().unwrap();
|
||||||
#[cfg(feature = "webview")]
|
|
||||||
{
|
|
||||||
let webview = &window.content;
|
let webview = &window.content;
|
||||||
|
|
||||||
match message {
|
match message {
|
||||||
|
@ -89,18 +86,15 @@ impl Dispatcher for BasicApp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct WebViewInstance;
|
pub struct WebViewInstance;
|
||||||
|
|
||||||
#[cfg(feature = "webview")]
|
|
||||||
impl WebViewDelegate for WebViewInstance {}
|
impl WebViewDelegate for WebViewInstance {}
|
||||||
|
|
||||||
struct AppWindow {
|
struct AppWindow {
|
||||||
toolbar: Toolbar<BrowserToolbar>,
|
toolbar: Toolbar<BrowserToolbar>,
|
||||||
#[cfg(feature = "webview")]
|
|
||||||
content: WebView<WebViewInstance>
|
content: WebView<WebViewInstance>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,14 +102,12 @@ impl AppWindow {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
AppWindow {
|
AppWindow {
|
||||||
toolbar: Toolbar::new("com.example.BrowserToolbar", BrowserToolbar::new()),
|
toolbar: Toolbar::new("com.example.BrowserToolbar", BrowserToolbar::new()),
|
||||||
#[cfg(feature = "webview")]
|
|
||||||
content: WebView::with(WebViewConfig::default(), WebViewInstance::default())
|
content: WebView::with(WebViewConfig::default(), WebViewInstance::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_url(&self, url: &str) {
|
pub fn load_url(&self, url: &str) {
|
||||||
self.toolbar.delegate.as_ref().unwrap().set_url(url);
|
self.toolbar.delegate.as_ref().unwrap().set_url(url);
|
||||||
#[cfg(feature = "webview")]
|
|
||||||
self.content.load_url(url);
|
self.content.load_url(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +121,6 @@ impl WindowDelegate for AppWindow {
|
||||||
window.set_minimum_content_size(400., 400.);
|
window.set_minimum_content_size(400., 400.);
|
||||||
|
|
||||||
window.set_toolbar(&self.toolbar);
|
window.set_toolbar(&self.toolbar);
|
||||||
#[cfg(feature = "webview")]
|
|
||||||
window.set_content_view(&self.content);
|
window.set_content_view(&self.content);
|
||||||
|
|
||||||
self.load_url("https://www.duckduckgo.com/");
|
self.load_url("https://www.duckduckgo.com/");
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
|
|
||||||
#[cfg(targe_os = "ios")]
|
|
||||||
use cacao::uikit::{App, AppDelegate, Scene, SceneConfig, SceneConnectionOptions, SceneSession, Window, WindowSceneDelegate};
|
use cacao::uikit::{App, AppDelegate, Scene, SceneConfig, SceneConnectionOptions, SceneSession, Window, WindowSceneDelegate};
|
||||||
|
|
||||||
use cacao::color::Color;
|
use cacao::color::Color;
|
||||||
|
@ -10,7 +9,6 @@ use cacao::view::{View, ViewController, ViewDelegate};
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct TestApp;
|
struct TestApp;
|
||||||
|
|
||||||
#[cfg(target_os= "ios")]
|
|
||||||
impl AppDelegate for TestApp {
|
impl AppDelegate for TestApp {
|
||||||
fn config_for_scene_session(&self, session: SceneSession, _options: SceneConnectionOptions) -> SceneConfig {
|
fn config_for_scene_session(&self, session: SceneSession, _options: SceneConnectionOptions) -> SceneConfig {
|
||||||
SceneConfig::new("Default Configuration", session.role())
|
SceneConfig::new("Default Configuration", session.role())
|
||||||
|
@ -57,12 +55,10 @@ impl ViewDelegate for RootView {
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct WindowScene {
|
pub struct WindowScene {
|
||||||
#[cfg(target_os= "ios")]
|
|
||||||
pub window: RwLock<Option<Window>>,
|
pub window: RwLock<Option<Window>>,
|
||||||
pub root_view_controller: RwLock<Option<ViewController<RootView>>>
|
pub root_view_controller: RwLock<Option<ViewController<RootView>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os= "ios")]
|
|
||||||
impl WindowSceneDelegate for WindowScene {
|
impl WindowSceneDelegate for WindowScene {
|
||||||
fn will_connect(&self, scene: Scene, session: SceneSession, options: SceneConnectionOptions) {
|
fn will_connect(&self, scene: Scene, session: SceneSession, options: SceneConnectionOptions) {
|
||||||
let bounds = scene.get_bounds();
|
let bounds = scene.get_bounds();
|
||||||
|
@ -84,6 +80,5 @@ impl WindowSceneDelegate for WindowScene {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(target_os= "ios")]
|
|
||||||
App::new(TestApp::default(), || Box::new(WindowScene::default())).run();
|
App::new(TestApp::default(), || Box::new(WindowScene::default())).run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ use cacao::appkit::toolbar::Toolbar;
|
||||||
use cacao::appkit::window::{Window, WindowConfig, WindowDelegate, WindowToolbarStyle};
|
use cacao::appkit::window::{Window, WindowConfig, WindowDelegate, WindowToolbarStyle};
|
||||||
use cacao::appkit::{App, AppDelegate};
|
use cacao::appkit::{App, AppDelegate};
|
||||||
|
|
||||||
#[cfg(feature = "webview")]
|
|
||||||
use cacao::webview::{WebView, WebViewConfig, WebViewDelegate};
|
use cacao::webview::{WebView, WebViewConfig, WebViewDelegate};
|
||||||
|
|
||||||
struct BasicApp {
|
struct BasicApp {
|
||||||
|
@ -86,7 +85,6 @@ impl AppWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "webview")]
|
|
||||||
impl WindowDelegate for AppWindow {
|
impl WindowDelegate for AppWindow {
|
||||||
const NAME: &'static str = "WindowDelegate";
|
const NAME: &'static str = "WindowDelegate";
|
||||||
|
|
||||||
|
@ -102,12 +100,9 @@ impl WindowDelegate for AppWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "webview")]
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new("com.test.window", BasicApp {
|
App::new("com.test.window", BasicApp {
|
||||||
window: Window::with(WindowConfig::default(), AppWindow::new())
|
window: Window::with(WindowConfig::default(), AppWindow::new())
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "webview"))]
|
|
||||||
fn main() {}
|
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
//!
|
//!
|
||||||
//! Views implement Autolayout, which enable you to specify how things should appear on the screen.
|
//! Views implement Autolayout, which enable you to specify how things should appear on the screen.
|
||||||
//!
|
//!
|
||||||
//! ```rust,compile_fail
|
//! ```rust
|
||||||
//! use cacao::color::Color;
|
//! use cacao::color::Color;
|
||||||
//! use cacao::layout::{Layout, LayoutConstraint};
|
//! use cacao::layout::{Layout, LayoutConstraint};
|
||||||
//! use cacao::view::View;
|
//! use cacao::view::View;
|
||||||
//! use cacao::window::{Window, WindowDelegate};
|
//! use cacao::appkit::window::{Window, WindowDelegate};
|
||||||
//!
|
//!
|
||||||
//! #[derive(Default)]
|
//! #[derive(Default)]
|
||||||
//! struct AppWindow {
|
//! struct AppWindow {
|
||||||
|
|
Loading…
Reference in a new issue