mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Fix sh/check.sh (#1446)
* Don't bother serializing date in widget gallery * Make egui_extras non-optional dependency of egui_demo_lib
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
#[cfg(feature = "datetime")]
|
||||
mod serde_date_format;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
enum Enum {
|
||||
@@ -20,9 +17,11 @@ pub struct WidgetGallery {
|
||||
string: String,
|
||||
color: egui::Color32,
|
||||
animate_progress_bar: bool,
|
||||
|
||||
#[cfg(feature = "datetime")]
|
||||
#[serde(with = "serde_date_format")]
|
||||
date: chrono::Date<chrono::Utc>,
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
date: Option<chrono::Date<chrono::Utc>>,
|
||||
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
texture: Option<egui::TextureHandle>,
|
||||
}
|
||||
@@ -39,7 +38,7 @@ impl Default for WidgetGallery {
|
||||
color: egui::Color32::LIGHT_BLUE.linear_multiply(0.5),
|
||||
animate_progress_bar: false,
|
||||
#[cfg(feature = "datetime")]
|
||||
date: chrono::offset::Utc::now().date(),
|
||||
date: None,
|
||||
texture: None,
|
||||
}
|
||||
}
|
||||
@@ -110,6 +109,7 @@ impl WidgetGallery {
|
||||
string,
|
||||
color,
|
||||
animate_progress_bar,
|
||||
#[cfg(feature = "datetime")]
|
||||
date,
|
||||
texture,
|
||||
} = self;
|
||||
@@ -212,6 +212,7 @@ impl WidgetGallery {
|
||||
|
||||
#[cfg(feature = "datetime")]
|
||||
{
|
||||
let date = date.get_or_insert_with(|| chrono::offset::Utc::now().date());
|
||||
ui.add(doc_link_label("DatePickerButton", "DatePickerButton"));
|
||||
ui.add(egui_extras::DatePickerButton::new(date));
|
||||
ui.end_row();
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
use chrono::{Date, NaiveDate, Utc};
|
||||
use serde::{self, Deserialize, Deserializer, Serializer};
|
||||
|
||||
const FORMAT: &str = "%Y-%m-%d";
|
||||
|
||||
pub fn serialize<S>(date: &Date<Utc>, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let s = date.format(FORMAT).to_string();
|
||||
serializer.serialize_str(&s)
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D>(deserializer: D) -> Result<Date<Utc>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let s = String::deserialize(deserializer)?;
|
||||
|
||||
NaiveDate::parse_from_str(&s, FORMAT)
|
||||
.map(|naive_date| Date::from_utc(naive_date, Utc))
|
||||
.map_err(serde::de::Error::custom)
|
||||
}
|
||||
Reference in New Issue
Block a user