T06b forms selection: checkbox, radio, cards, switch, select, combobox, multi select, cascader, transfer list, list box, chips, rating, sliders, knob, stepper
This commit is contained in:
36 files changed
+5170
-198
No files matched your search
@@ -0,0 +1,26 @@
|
||||
use gpui::{App, ElementId, Window};
|
||||
|
||||
struct Changes<T> {
|
||||
last: T,
|
||||
count: usize,
|
||||
}
|
||||
|
||||
/// How often `value` changed since `id` first rendered. Key an animation on it to replay per change.
|
||||
pub(crate) fn changes<T: Clone + PartialEq + 'static>(
|
||||
id: impl Into<ElementId>,
|
||||
value: T,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> usize {
|
||||
let state = window.use_keyed_state(id, cx, |_, _| Changes {
|
||||
last: value.clone(),
|
||||
count: 0,
|
||||
});
|
||||
if state.read(cx).last != value {
|
||||
state.update(cx, |state, _| {
|
||||
state.last = value;
|
||||
state.count += 1;
|
||||
});
|
||||
}
|
||||
state.read(cx).count
|
||||
}
|
||||
Reference in new issue
Block a user