use chrono::{DateTime, Utc}; use crate::location::FLocation; use ratatui::{style::Color, text::Line, widgets::{ListItem, ListState}}; #[derive(Clone,Debug)] pub enum CurrentScreen { Map, CityChoice, Exiting } #[derive(Debug,Clone,PartialEq)] pub struct City { pub name: String, pub long: f32, pub lat: f32, } impl From<&City> for ListItem<'_> { fn from(value: &City) -> Self { let line = Line::styled( format!("{} : {} W/E , {} N/S",value.name,value.long,value.lat), Color::Gray); ListItem::new(line) } } /// uuuhhh future feature. /// checking if the currently chosen city is within the ISS's visibility (https://tangled.sh/@technoduck.me/iss_locator.rs) pub const CITIES:[(&str,f32,f32);9] = [ ("Montreal",-72.2,45.5), ("Tokyo",139.766,35.66), ("Delhi",77.216,28.6), ("Shanghai",121.45,31.22), ("São Paulo",-46.65,-23.55), ("Mexico City",-99.12,19.45), ("Cairo",31.233,30.03), ("New York",-74.0,40.7), ("London",0.03,51.55) ]; impl From<&(&str,f32,f32)> for City { fn from(value: &(&str,f32,f32)) -> Self { City { name: value.0.to_string(), long: value.1, lat: value.2 } } } #[derive(Clone,Debug)] pub struct CityList { pub cities: Vec, pub state: ListState } #[derive(Clone,Debug)] pub struct App { pub current_screen: CurrentScreen, pub cities: CityList, pub iss_location: Option, pub getting_location: bool, pub iss_constant: Option, pub iss_constant_epoch: Option> } impl App { pub fn new() -> App { let cities_vec:Vec = CITIES.iter() .map(|f| City::from(f)) .collect(); let cities:CityList = CityList { cities: cities_vec, state: ListState::default() }; App { current_screen:CurrentScreen::Map, cities, iss_location: None, getting_location: false, iss_constant: None, iss_constant_epoch: None } } }