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:
|
||||
command: fmt
|
||||
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:
|
||||
name: Check that the code builds
|
||||
runs-on: macos-latest
|
||||
|
@ -42,9 +54,6 @@ jobs:
|
|||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
|
|
11
Cargo.toml
11
Cargo.toml
|
@ -53,3 +53,14 @@ identifier = "com.cacao.ios-test"
|
|||
category = "Developer Tool"
|
||||
short_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.
|
||||
|
||||
use cacao::notification_center::Dispatcher;
|
||||
#[cfg(feature = "webview")]
|
||||
use cacao::webview::{WebView, WebViewConfig, WebViewDelegate};
|
||||
|
||||
use cacao::appkit::menu::{Menu, MenuItem};
|
||||
|
@ -73,8 +72,6 @@ impl Dispatcher for BasicApp {
|
|||
|
||||
fn on_ui_message(&self, message: Self::Message) {
|
||||
let window = self.window.delegate.as_ref().unwrap();
|
||||
#[cfg(feature = "webview")]
|
||||
{
|
||||
let webview = &window.content;
|
||||
|
||||
match message {
|
||||
|
@ -90,17 +87,14 @@ impl Dispatcher for BasicApp {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct WebViewInstance;
|
||||
|
||||
#[cfg(feature = "webview")]
|
||||
impl WebViewDelegate for WebViewInstance {}
|
||||
|
||||
struct AppWindow {
|
||||
toolbar: Toolbar<BrowserToolbar>,
|
||||
#[cfg(feature = "webview")]
|
||||
content: WebView<WebViewInstance>
|
||||
}
|
||||
|
||||
|
@ -108,14 +102,12 @@ impl AppWindow {
|
|||
pub fn new() -> Self {
|
||||
AppWindow {
|
||||
toolbar: Toolbar::new("com.example.BrowserToolbar", BrowserToolbar::new()),
|
||||
#[cfg(feature = "webview")]
|
||||
content: WebView::with(WebViewConfig::default(), WebViewInstance::default())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_url(&self, url: &str) {
|
||||
self.toolbar.delegate.as_ref().unwrap().set_url(url);
|
||||
#[cfg(feature = "webview")]
|
||||
self.content.load_url(url);
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +121,6 @@ impl WindowDelegate for AppWindow {
|
|||
window.set_minimum_content_size(400., 400.);
|
||||
|
||||
window.set_toolbar(&self.toolbar);
|
||||
#[cfg(feature = "webview")]
|
||||
window.set_content_view(&self.content);
|
||||
|
||||
self.load_url("https://www.duckduckgo.com/");
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::sync::RwLock;
|
||||
|
||||
#[cfg(targe_os = "ios")]
|
||||
use cacao::uikit::{App, AppDelegate, Scene, SceneConfig, SceneConnectionOptions, SceneSession, Window, WindowSceneDelegate};
|
||||
|
||||
use cacao::color::Color;
|
||||
|
@ -10,7 +9,6 @@ use cacao::view::{View, ViewController, ViewDelegate};
|
|||
#[derive(Default)]
|
||||
struct TestApp;
|
||||
|
||||
#[cfg(target_os= "ios")]
|
||||
impl AppDelegate for TestApp {
|
||||
fn config_for_scene_session(&self, session: SceneSession, _options: SceneConnectionOptions) -> SceneConfig {
|
||||
SceneConfig::new("Default Configuration", session.role())
|
||||
|
@ -57,12 +55,10 @@ impl ViewDelegate for RootView {
|
|||
|
||||
#[derive(Default)]
|
||||
pub struct WindowScene {
|
||||
#[cfg(target_os= "ios")]
|
||||
pub window: RwLock<Option<Window>>,
|
||||
pub root_view_controller: RwLock<Option<ViewController<RootView>>>
|
||||
}
|
||||
|
||||
#[cfg(target_os= "ios")]
|
||||
impl WindowSceneDelegate for WindowScene {
|
||||
fn will_connect(&self, scene: Scene, session: SceneSession, options: SceneConnectionOptions) {
|
||||
let bounds = scene.get_bounds();
|
||||
|
@ -84,6 +80,5 @@ impl WindowSceneDelegate for WindowScene {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
#[cfg(target_os= "ios")]
|
||||
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::{App, AppDelegate};
|
||||
|
||||
#[cfg(feature = "webview")]
|
||||
use cacao::webview::{WebView, WebViewConfig, WebViewDelegate};
|
||||
|
||||
struct BasicApp {
|
||||
|
@ -86,7 +85,6 @@ impl AppWindow {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "webview")]
|
||||
impl WindowDelegate for AppWindow {
|
||||
const NAME: &'static str = "WindowDelegate";
|
||||
|
||||
|
@ -102,12 +100,9 @@ impl WindowDelegate for AppWindow {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "webview")]
|
||||
fn main() {
|
||||
App::new("com.test.window", BasicApp {
|
||||
window: Window::with(WindowConfig::default(), AppWindow::new())
|
||||
})
|
||||
.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.
|
||||
//!
|
||||
//! ```rust,compile_fail
|
||||
//! ```rust
|
||||
//! use cacao::color::Color;
|
||||
//! use cacao::layout::{Layout, LayoutConstraint};
|
||||
//! use cacao::view::View;
|
||||
//! use cacao::window::{Window, WindowDelegate};
|
||||
//! use cacao::appkit::window::{Window, WindowDelegate};
|
||||
//!
|
||||
//! #[derive(Default)]
|
||||
//! struct AppWindow {
|
||||
|
|
Loading…
Reference in a new issue