Compare commits
2 commits
5fc628a54d
...
e041349ee9
Author | SHA1 | Date | |
---|---|---|---|
|
e041349ee9 | ||
|
ceb3764a20 |
2 changed files with 70 additions and 9 deletions
|
@ -23,6 +23,7 @@ static KEYRING: OnceLock<oo7::Keyring> = OnceLock::new();
|
|||
pub enum LoginInput {
|
||||
LogOut,
|
||||
NeedsLogin,
|
||||
ConsentToLogin,
|
||||
NeedsRefresh,
|
||||
ReceivedAuthCode(String),
|
||||
BreakWorld,
|
||||
|
@ -30,6 +31,7 @@ pub enum LoginInput {
|
|||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum LoginState {
|
||||
Beginning,
|
||||
InFlow,
|
||||
Offline,
|
||||
}
|
||||
|
@ -91,15 +93,71 @@ impl AsyncComponent for Login {
|
|||
#[root]
|
||||
adw::Bin {
|
||||
#[wrap(Some)]
|
||||
#[name = "webview"]
|
||||
set_child = &WebView::builder().web_context(&webcontext).build() {
|
||||
#[track(model.changed(Self::state()))]
|
||||
set_visible: model.state == LoginState::InFlow,
|
||||
set_child = &adw::ToolbarView {
|
||||
add_top_bar = &adw::HeaderBar {},
|
||||
|
||||
#[wrap(Some)]
|
||||
set_content = &adw::ViewStack {
|
||||
|
||||
#[track(model.changed_state() && model.state == LoginState::InFlow)]
|
||||
load_request?: &model.construct_request_uri(),
|
||||
}
|
||||
#[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)]
|
||||
#[name = "webview"]
|
||||
set_child = &WebView::builder().web_context(&webcontext).build() {
|
||||
set_margin_all: 12,
|
||||
// TODO: make webkitview rounded
|
||||
#[track(model.changed_state() && model.state == LoginState::InFlow)]
|
||||
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(),
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,8 +316,12 @@ impl AsyncComponent for Login {
|
|||
self.flow_model.replace(None);
|
||||
}
|
||||
LoginInput::NeedsLogin => {
|
||||
self.set_state(LoginState::InFlow);
|
||||
self.set_state(LoginState::Beginning);
|
||||
sender.output(LoginOutput::RequiresLogin).unwrap();
|
||||
}
|
||||
LoginInput::ConsentToLogin => {
|
||||
sender.output(LoginOutput::RequiresLogin).unwrap();
|
||||
self.set_state(LoginState::InFlow);
|
||||
self.flow_model.replace(Some(LoginFlowModel {
|
||||
code_verifier: CodeVerfier::new(),
|
||||
nonce: create_nonce(),
|
||||
|
|
|
@ -59,7 +59,6 @@ impl Component for TrackingView {
|
|||
set_child = >k::Box {
|
||||
set_orientation: gtk::Orientation::Horizontal,
|
||||
set_margin_all: 2,
|
||||
set_halign: gtk::Align::Center,
|
||||
|
||||
add_css_class: relm4::css::TOOLBAR,
|
||||
|
||||
|
|
Loading…
Reference in a new issue