mod logger;
mod cache;
mod camera;
mod share;
mod clipboard;
mod app_support;
mod cloud;
mod haptics;
mod photo_picker;
mod safe_area;
mod notifications;
use std::sync::mpsc::Sender;
pub use cache::Cache;
pub use clipboard::Clipboard;
pub use camera::{Camera, CameraError};
pub use camera::ImageSettings;
pub use share::Share;
pub use app_support::ApplicationSupport;
pub use cloud::CloudStorage;
pub use photo_picker::{PhotoPicker, ImageOrientation};
pub use safe_area::SafeAreaInsets;
pub use haptics::Haptics;
pub use notifications::Notifications;
#[derive(Clone)]
pub struct Context {
pub cache: Cache
}
impl Context {
pub(crate) fn new() -> Self {
Clipboard::new();
logger::Logger::start(None);
Self {
cache: Cache::new(),
}
}
#[doc = include_str!("examples/register_notifs.rs")]
pub fn register_notifs(&self) {
Notifications::register();
}
#[doc = include_str!("examples/push_notifs.rs")]
pub fn push_notification(&self, title: &str, msg: &str) {
Notifications::push(title, msg);
}
#[doc = include_str!("examples/haptic.rs")]
pub fn haptic(&self) {
Haptics::vibrate()
}
#[doc = include_str!("examples/safe_area.rs")]
pub fn safe_area_insets(&self) -> (f32, f32, f32, f32) {
SafeAreaInsets::get()
}
#[doc = include_str!("examples/open_camera.rs")]
pub fn open_camera(&self) -> Result<Camera, CameraError> {
Camera::new()
}
#[doc = include_str!("examples/open_unprocessed.rs")]
pub fn open_unprocessed_camera(&self) -> Result<Camera, CameraError> {
Camera::new_unprocessed()
}
#[doc = include_str!("examples/paste.rs")]
pub fn paste(&self) -> String {
Clipboard::get()
}
#[doc = include_str!("examples/copy.rs")]
pub fn copy(&self, text: String) {
Clipboard::set(text);
}
#[doc = include_str!("examples/share.rs")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub fn share(&self, text: &str) {
Share::share(text);
}
#[doc = include_str!("examples/share_image.rs")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub fn share_image(&self, image: image::RgbaImage) {
Share::share_image(image);
}
#[doc = include_str!("examples/open_photo_picker.rs")]
pub fn open_photo_picker(&self, sender: Sender<(Vec<u8>, ImageOrientation)>) {
PhotoPicker::open(sender);
}
#[doc = include_str!("examples/cloud_save.rs")]
pub fn cloud_save(&self, key: &str, value: &str) -> Result<(), String> {
CloudStorage::save(key, value)
}
#[doc = include_str!("examples/cloud_get.rs")]
pub fn cloud_get(&self, key: &str) -> Option<String> {
CloudStorage::get(key).ok().flatten()
}
#[doc = include_str!("examples/cloud_remove.rs")]
pub fn cloud_remove(&self, key: &str) -> Result<(), String> {
CloudStorage::remove(key)
}
#[doc = include_str!("examples/cloud_clear.rs")]
pub fn cloud_clear(&self) -> Result<(), String> {
CloudStorage::clear()
}
}