Compare commits
No commits in common. "e041349ee97941952bde32285b89f4d524904ee7" and "5fc628a54d41922a540e4888c70fd5eed1eb41c4" have entirely different histories.
e041349ee9
...
5fc628a54d
2 changed files with 9 additions and 70 deletions
|
@ -23,7 +23,6 @@ static KEYRING: OnceLock<oo7::Keyring> = OnceLock::new();
|
||||||
pub enum LoginInput {
|
pub enum LoginInput {
|
||||||
LogOut,
|
LogOut,
|
||||||
NeedsLogin,
|
NeedsLogin,
|
||||||
ConsentToLogin,
|
|
||||||
NeedsRefresh,
|
NeedsRefresh,
|
||||||
ReceivedAuthCode(String),
|
ReceivedAuthCode(String),
|
||||||
BreakWorld,
|
BreakWorld,
|
||||||
|
@ -31,7 +30,6 @@ pub enum LoginInput {
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum LoginState {
|
pub enum LoginState {
|
||||||
Beginning,
|
|
||||||
InFlow,
|
InFlow,
|
||||||
Offline,
|
Offline,
|
||||||
}
|
}
|
||||||
|
@ -92,73 +90,17 @@ impl AsyncComponent for Login {
|
||||||
view! {
|
view! {
|
||||||
#[root]
|
#[root]
|
||||||
adw::Bin {
|
adw::Bin {
|
||||||
#[wrap(Some)]
|
|
||||||
set_child = &adw::ToolbarView {
|
|
||||||
add_top_bar = &adw::HeaderBar {},
|
|
||||||
|
|
||||||
#[wrap(Some)]
|
|
||||||
set_content = &adw::ViewStack {
|
|
||||||
|
|
||||||
#[name = "page_beginning"]
|
|
||||||
add = &adw::Bin {
|
|
||||||
#[wrap(Some)]
|
|
||||||
set_child = &adw::StatusPage {
|
|
||||||
set_title: "Welcome to Paket!",
|
|
||||||
#[wrap(Some)]
|
|
||||||
set_child = &adw::Clamp {
|
|
||||||
set_maximum_size: 260,
|
|
||||||
|
|
||||||
#[wrap(Some)]
|
|
||||||
set_child = >k::Button {
|
|
||||||
add_css_class: relm4::css::SUGGESTED_ACTION,
|
|
||||||
add_css_class: relm4::css::PILL,
|
|
||||||
|
|
||||||
set_label: "Log In",
|
|
||||||
|
|
||||||
connect_clicked => LoginInput::ConsentToLogin,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
#[name = "page_webview"]
|
|
||||||
add = &adw::Bin {
|
|
||||||
#[wrap(Some)]
|
|
||||||
set_child = &adw::Clamp {
|
|
||||||
#[wrap(Some)]
|
|
||||||
set_child = &adw::Bin {
|
|
||||||
add_css_class: relm4::css::CARD,
|
|
||||||
set_margin_all: 12,
|
|
||||||
|
|
||||||
#[wrap(Some)]
|
#[wrap(Some)]
|
||||||
#[name = "webview"]
|
#[name = "webview"]
|
||||||
set_child = &WebView::builder().web_context(&webcontext).build() {
|
set_child = &WebView::builder().web_context(&webcontext).build() {
|
||||||
set_margin_all: 12,
|
#[track(model.changed(Self::state()))]
|
||||||
// TODO: make webkitview rounded
|
set_visible: model.state == LoginState::InFlow,
|
||||||
|
|
||||||
|
|
||||||
#[track(model.changed_state() && model.state == LoginState::InFlow)]
|
#[track(model.changed_state() && model.state == LoginState::InFlow)]
|
||||||
load_request?: &model.construct_request_uri(),
|
load_request?: &model.construct_request_uri(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
#[name = "page_offline"]
|
|
||||||
add = &adw::Bin {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
#[track(model.changed_state())]
|
|
||||||
set_visible_child: {
|
|
||||||
match model.state {
|
|
||||||
LoginState::Beginning => page_beginning.widget_ref(),
|
|
||||||
LoginState::Offline => page_offline.widget_ref(),
|
|
||||||
LoginState::InFlow => page_webview.widget_ref(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn init(
|
async fn init(
|
||||||
|
@ -316,12 +258,8 @@ impl AsyncComponent for Login {
|
||||||
self.flow_model.replace(None);
|
self.flow_model.replace(None);
|
||||||
}
|
}
|
||||||
LoginInput::NeedsLogin => {
|
LoginInput::NeedsLogin => {
|
||||||
self.set_state(LoginState::Beginning);
|
|
||||||
sender.output(LoginOutput::RequiresLogin).unwrap();
|
|
||||||
}
|
|
||||||
LoginInput::ConsentToLogin => {
|
|
||||||
sender.output(LoginOutput::RequiresLogin).unwrap();
|
|
||||||
self.set_state(LoginState::InFlow);
|
self.set_state(LoginState::InFlow);
|
||||||
|
sender.output(LoginOutput::RequiresLogin).unwrap();
|
||||||
self.flow_model.replace(Some(LoginFlowModel {
|
self.flow_model.replace(Some(LoginFlowModel {
|
||||||
code_verifier: CodeVerfier::new(),
|
code_verifier: CodeVerfier::new(),
|
||||||
nonce: create_nonce(),
|
nonce: create_nonce(),
|
||||||
|
|
|
@ -59,6 +59,7 @@ impl Component for TrackingView {
|
||||||
set_child = >k::Box {
|
set_child = >k::Box {
|
||||||
set_orientation: gtk::Orientation::Horizontal,
|
set_orientation: gtk::Orientation::Horizontal,
|
||||||
set_margin_all: 2,
|
set_margin_all: 2,
|
||||||
|
set_halign: gtk::Align::Center,
|
||||||
|
|
||||||
add_css_class: relm4::css::TOOLBAR,
|
add_css_class: relm4::css::TOOLBAR,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue