diff options
| author | 2025-01-23 23:30:10 -0600 | |
|---|---|---|
| committer | 2025-01-23 23:30:10 -0600 | |
| commit | 524cff04a2ed0516a52ffd2e3a15118633ee1cd8 (patch) | |
| tree | 53de47c6505b01162d8ebfe46d9ab1a6f0310946 /ozone-ui/src/main.rs | |
| parent | make auth module (diff) | |
interactive auth testing
Diffstat (limited to 'ozone-ui/src/main.rs')
| -rw-r--r-- | ozone-ui/src/main.rs | 96 |
1 files changed, 34 insertions, 62 deletions
diff --git a/ozone-ui/src/main.rs b/ozone-ui/src/main.rs index 728953d..0d578a1 100644 --- a/ozone-ui/src/main.rs +++ b/ozone-ui/src/main.rs @@ -1,69 +1,41 @@ -use iced::widget::{button, column, container, horizontal_rule, row, text, vertical_rule}; -use iced::window::Settings; -use iced::{Element, Fill, FillPortion, Theme}; +use std::borrow::Cow; +use reqwest::Url; +use slint::run_event_loop; +use wry::http::{Response, StatusCode}; +use wry::{WebViewBuilder, WebViewBuilderExtWindows}; -fn main() -> iced::Result { - let mut settings = Settings::default(); +slint::slint! { + export component HelloWorld inherits Window { - settings.size = [640.0, 480.0].into(); - settings.min_size = Some([320.0, 200.0].into()); - - iced::application("Title", update, view) - .window(settings) - .theme(|s: &State| { - Theme::ALL[(s.count as usize) % Theme::ALL.len()].clone() - }) - .run() + } } -#[derive(Debug, Clone, Default)] -struct State { - count: u64 -} +fn main() { + simple_logger::SimpleLogger::new().env().init().unwrap(); -#[derive(Debug, Clone, Copy)] -enum Message { - Increment, - Decrement -} + let hw = HelloWorld::new().unwrap(); + hw.show().unwrap(); -fn update(counter: &mut State, message: Message) { - match message { - Message::Increment => counter.count = counter.count.wrapping_add(1), - Message::Decrement => counter.count = counter.count.wrapping_sub(1), - } -} + let wv = WebViewBuilder::new() + .with_url("https://login.live.com/oauth20_authorize.srf?client_id=00000000402b5328&redirect_uri=ms-xal-00000000402b5328://auth&response_type=token&display=touch&scope=service::user.auth.xboxlive.com::MBI_SSL%20offline_access&prompt=select_account") + .with_navigation_handler(|url| { + let mut url = match reqwest::Url::parse(url.as_str()) { + Ok(url) => url, + Err(_) => return true + }; -fn view(counter: &State) -> Element<Message> { - container(column([ - container(row([ - button("amogus") - .style(button::text) - .on_press(Message::Decrement).into() - ])) - .style(container::bordered_box) - .width(Fill) - .into(), - row([ - container("this is where a sane person might choose a profile to play.") - .width(FillPortion(3)) - .height(Fill).into(), - vertical_rule(1).into(), - container("the goddamn user interface.") - .width(Fill).into() - ]).height(Fill).into(), - horizontal_rule(1).into(), - container(row([ - text("yippee!!").height(Fill).width(Fill).into(), - container(button(text("Play").height(Fill).width(Fill).center()).style(button::primary).on_press(Message::Increment)).max_width(150.0).into(), - text("you're logged in or something").height(Fill).width(Fill).into(), - ]) - .padding(10) - .spacing(10)) - .height(75).into(), - container(text(format!("Counter: {}", counter.count))).padding(5).width(Fill).style(container::bordered_box).into() - ])) - .center_x(Fill) - .center_y(Fill) - .into() -}
\ No newline at end of file + + if url.scheme() == "ms-xal-00000000402b5328" { + let fragment = url.fragment().map(|s| s.to_owned()); + url.set_query(fragment.as_ref().map(|s| s.as_str())); + url.query_pairs().inspect(|p| println!("{:?}", p)).for_each(drop); + dbg!(url); + + return false; + } + + true + }).build(&hw.window().window_handle()).unwrap(); + + run_event_loop().unwrap(); +} |
