use toolkit_zero::location::browser::{PageTemplate, LocationData, LocationError, browser};
fn main() {
println!("=== browser macro demo (PageTemplate construction) ===\n");
demo_page_templates();
println!("PageTemplate demos complete ✓");
println!();
println!("The #[browser] macro forms below are compiled but not executed.");
println!("To capture a real location, call one of the async fns defined");
println!("further down the file from a #[tokio::main] async fn main.");
}
fn demo_page_templates() {
let _blank = PageTemplate::Default {
title: None,
body_text: None,
};
println!(" Default (blank)");
let _with_title = PageTemplate::Default {
title: Some("My App — Location".into()),
body_text: None,
};
println!(" Default (title only)");
let _with_both = PageTemplate::Default {
title: Some("Location Access".into()),
body_text: Some("We need your location to show nearby results.".into()),
};
println!(" Default (title + body)");
let _tickbox_blank = PageTemplate::Tickbox {
title: None,
body_text: None,
consent_text: None,
};
println!(" Tickbox (all defaults)");
let _tickbox_full = PageTemplate::Tickbox {
title: Some("Verify Your Location".into()),
body_text: Some("Tick to grant access and continue.".into()),
consent_text: Some("I agree to share my location with this app.".into()),
};
println!(" Tickbox (fully populated)");
let _custom = PageTemplate::Custom(
"<html><head><title>Loc</title></head>\
<body><p>Getting your location…</p></body></html>"
.into(),
);
println!(" Custom HTML");
}
#[allow(dead_code)]
async fn location_default() -> Result<LocationData, LocationError> {
#[browser]
fn loc() {}
Ok(loc)
}
#[allow(dead_code)]
async fn location_with_title() -> Result<LocationData, LocationError> {
#[browser(title = "Share Your Location")]
fn loc() {}
Ok(loc)
}
#[allow(dead_code)]
async fn location_with_title_and_body() -> Result<LocationData, LocationError> {
#[browser(title = "Location Required", body = "Please allow access to continue.")]
fn loc() {}
Ok(loc)
}
#[allow(dead_code)]
async fn location_tickbox() -> Result<LocationData, LocationError> {
#[browser(tickbox)]
fn loc() {}
Ok(loc)
}
#[allow(dead_code)]
async fn location_tickbox_full() -> Result<LocationData, LocationError> {
#[browser(tickbox, title = "Location Consent", body = "Click the box below.", consent = "I agree")]
fn loc() {}
Ok(loc)
}
#[allow(dead_code)]
async fn location_custom_html() -> Result<LocationData, LocationError> {
#[browser(html = "<html><body><h1>Fetching location…</h1></body></html>")]
fn loc() {}
Ok(loc)
}
#[allow(dead_code)]
fn location_sync() -> Result<LocationData, LocationError> {
#[browser(sync)]
fn loc() {}
Ok(loc)
}
#[allow(dead_code)]
fn location_sync_with_title() -> Result<LocationData, LocationError> {
#[browser(sync, title = "Location (sync)")]
fn loc() {}
Ok(loc)
}
#[allow(dead_code)]
fn location_sync_custom_html() -> Result<LocationData, LocationError> {
#[browser(sync, html = "<html><body><p>Getting location…</p></body></html>")]
fn loc() {}
Ok(loc)
}