Skip to content

Commit

Permalink
Adds a banner to the web version advertising the existance of the nat…
Browse files Browse the repository at this point in the history
…ive version (#41)

* Add a small ad to download the native version

* Add a tooltip; Fix positioning

* Bump version

* Format code
  • Loading branch information
margual56 authored Jan 20, 2024
1 parent 2fa6dcb commit ced5de2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions locales/ads.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"lbl.ad.native": {
"en": "Please consider using the native version for a better experience.",
"es": "Por favor, considere usar la versión nativa para una mejor experiencia."
},
"lbl.ad.exe": {
"en": "Click to download.",
"es": "Haz click aquí para descargarla."
},
"lbl.ad.explanation": {
"en": "The native version has code autosaving, persistent configuration, and more.",
"es": "La versión nativa tiene autoguardado de código, configuración persistente, y más."
}
}
34 changes: 33 additions & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ impl MyApp {

if ui.link(t!("menu.repository", lang)).clicked() {
webbrowser::open(
"https://github.com/margual56/turing-machine-2.0",
"https://github.com/turing-marcos/turing-machine",
)
.unwrap();
}
Expand Down Expand Up @@ -1167,6 +1167,38 @@ impl MyApp {
}
});
});

#[cfg(target_family = "wasm")]
{
let child_size = egui::Rect::from_center_size(
egui::pos2(
main_panel.cursor().center().x,
ctx.available_rect().center_bottom().y - 50.0,
),
egui::Vec2::new(ctx.available_rect().width() / 2.0, 30.0),
);
let mut popup = main_panel.child_ui(child_size, egui::Layout::default());
ctx.set_debug_on_hover(true);
egui::Frame::popup(&ctx.style())
.stroke(egui::Stroke::NONE)
.fill(Color32::from_rgba_unmultiplied(0, 0, 0, 0))
.show(&mut popup, |ui| {
ui.vertical_centered(|ui| {
ui.horizontal(|ui| {
ui.label(t!("lbl.ad.native", &lang));

if ui.link(t!("lbl.ad.exe", &lang)).clicked() {
webbrowser::open(
"https://github.com/turing-marcos/turing-machine/releases/latest",
)
.unwrap();
}
});
});
})
.response
.on_hover_text_at_pointer(t!("lbl.ad.explanation", &lang));
}
});
}
}
Expand Down

0 comments on commit ced5de2

Please sign in to comment.