Skip to content

Commit

Permalink
update and change dependencies before Pushing release.
Browse files Browse the repository at this point in the history
  • Loading branch information
genusistimelord committed Jul 28, 2023
1 parent e25046e commit 12c3bc0
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 62 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Breaking Selection list Message Type is now Name((usize, T)) for on_select.
- Upgraded to Latest Iced 0.10.0.
- Depreciating Older Versions of Iced_aw.
- Switched lazy_static to OnceCell

### Fixed
- Floating Element Position is corrected. Original position issue was due to Center_x containg both X and Width/2.
11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ categories = ["gui"]
[features]
badge = []
card = []
date_picker = ["chrono", "lazy_static", "icon_text"]
date_picker = ["chrono", "once_cell", "icon_text"]
color_picker = ["icon_text", "iced_widget/canvas"]
cupertino = ["iced_widget/canvas", "time"]
floating_element = []
Expand Down Expand Up @@ -59,11 +59,10 @@ default = [
]

[dependencies]
num-traits = { version = "0.2.15", optional = true }
time = { version = "0.3.5", features = ["local-offset"], optional = true }
chrono = { version = "0.4.23", optional = true }
lazy_static = { version = "1.4.0", optional = true }

num-traits = { version = "0.2.16", optional = true }
time = { version = "0.3.23", features = ["local-offset"], optional = true }
chrono = { version = "0.4.26", optional = true }
once_cell = { version = "1.18.0", optional = true }


[dependencies.iced_widget]
Expand Down
107 changes: 53 additions & 54 deletions src/core/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use chrono::Local;

use chrono::{Datelike, Duration, NaiveDate};

use lazy_static::lazy_static;
use once_cell::sync::Lazy;

/// The date value
#[derive(Clone, Copy, Debug, Default)]
Expand Down Expand Up @@ -222,59 +222,58 @@ pub fn month_as_string(date: NaiveDate) -> String {
date.format("%B").to_string()
}

lazy_static! {
/// Gets the length of the longest month name.
pub static ref MAX_MONTH_STR_LEN: usize = {
let months = [
NaiveDate::from_ymd_opt(0, 1, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 2, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 3, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 4, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 5, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 6, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 7, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 8, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 9, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 10, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 11, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 12, 1).expect("Year, Month or Day doesnt Exist"),
];

let max = months.iter()
.map(|m| month_as_string(*m))
.map(|s| s.len())
.max().expect("There should be a maximum element");

max
};

/// Gets the labels of the weekdays containing the first two characters of
/// the weekdays.
pub static ref WEEKDAY_LABELS: Vec<String> = {
let days = [
// Monday
NaiveDate::from_ymd_opt(2020, 6, 1).expect("Year, Month or Day doesnt Exist"),
// Tuesday
NaiveDate::from_ymd_opt(2020, 6, 2).expect("Year, Month or Day doesnt Exist"),
// Wednesday
NaiveDate::from_ymd_opt(2020, 6, 3).expect("Year, Month or Day doesnt Exist"),
// Thursday
NaiveDate::from_ymd_opt(2020, 6, 4).expect("Year, Month or Day doesnt Exist"),
// Friday
NaiveDate::from_ymd_opt(2020, 6, 5).expect("Year, Month or Day doesnt Exist"),
// Saturday
NaiveDate::from_ymd_opt(2020, 6, 6).expect("Year, Month or Day doesnt Exist"),
// Sunday
NaiveDate::from_ymd_opt(2020, 6, 7).expect("Year, Month or Day doesnt Exist"),

];

days.iter()
.map(|d| d.format("%a").to_string())
.map(|s| s[0..2].to_owned())
.collect()
};
}
/// Gets the length of the longest month name.
pub static MAX_MONTH_STR_LEN: Lazy<usize> = Lazy::new(|| {
let months = [
NaiveDate::from_ymd_opt(0, 1, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 2, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 3, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 4, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 5, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 6, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 7, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 8, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 9, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 10, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 11, 1).expect("Year, Month or Day doesnt Exist"),
NaiveDate::from_ymd_opt(0, 12, 1).expect("Year, Month or Day doesnt Exist"),
];

let max = months
.iter()
.map(|m| month_as_string(*m))
.map(|s| s.len())
.max()
.expect("There should be a maximum element");

max
});

/// Gets the labels of the weekdays containing the first two characters of
/// the weekdays.
pub static WEEKDAY_LABELS: Lazy<Vec<String>> = Lazy::new(|| {
let days = [
// Monday
NaiveDate::from_ymd_opt(2020, 6, 1).expect("Year, Month or Day doesnt Exist"),
// Tuesday
NaiveDate::from_ymd_opt(2020, 6, 2).expect("Year, Month or Day doesnt Exist"),
// Wednesday
NaiveDate::from_ymd_opt(2020, 6, 3).expect("Year, Month or Day doesnt Exist"),
// Thursday
NaiveDate::from_ymd_opt(2020, 6, 4).expect("Year, Month or Day doesnt Exist"),
// Friday
NaiveDate::from_ymd_opt(2020, 6, 5).expect("Year, Month or Day doesnt Exist"),
// Saturday
NaiveDate::from_ymd_opt(2020, 6, 6).expect("Year, Month or Day doesnt Exist"),
// Sunday
NaiveDate::from_ymd_opt(2020, 6, 7).expect("Year, Month or Day doesnt Exist"),
];

days.iter()
.map(|d| d.format("%a").to_string())
.map(|s| s[0..2].to_owned())
.collect()
});

#[cfg(test)]

Expand Down
2 changes: 1 addition & 1 deletion src/native/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
//! # Example
//!
//! ```
//! ```ignore
//! use iced::widget::button;
//! use iced_aw::menu::{MenuTree, MenuBar};
//!
Expand Down
2 changes: 1 addition & 1 deletion src/native/time_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub use crate::style::time_picker::{Appearance, StyleSheet};
///
/// # Example
/// ```ignore
/// # use iced_aw::{TimePicker,time_picker};
/// # use iced_aw::{TimePicker, time_picker};
/// # use iced_native::widget::{button, Button, Text};
/// #
/// #[derive(Clone, Debug)]
Expand Down

0 comments on commit 12c3bc0

Please sign in to comment.