void property_animation_update_animated_numbers(PropertyAnimation *property_animation, const uint32_t distance_normalized) { WeatherDataViewNumbers from, to; property_animation_from(property_animation, &from, sizeof(from), false); property_animation_to(property_animation, &to, sizeof(to), false); WeatherDataViewNumbers current = (WeatherDataViewNumbers) { .temperature = distance_interpolate(distance_normalized, from.temperature, to.temperature), .high = distance_interpolate(distance_normalized, from.high, to.high), .low = distance_interpolate(distance_normalized, from.low, to.low), }; PropertyAnimationImplementation *impl = (PropertyAnimationImplementation *) animation_get_implementation((Animation *) property_animation); WeatherDataAnimatedNumbersSetter setter = (WeatherDataAnimatedNumbersSetter)impl->accessors.setter.grect; void *subject; if (property_animation_get_subject(property_animation, &subject) && subject) { setter(subject, current); } } static const PropertyAnimationImplementation s_animated_numbers_implementation = { .base = { .update = (AnimationUpdateImplementation) property_animation_update_animated_numbers, }, .accessors = { .setter = { .grect = (const GRectSetter) set_animated_numbers, }, .getter = { .grect = (const GRectGetter) get_animated_numbers, }, },
static Animation *activity_indicator_layer_create_animation(Layer *layer) { Animation *animations[3]; const uint32_t duration = 1000; uint32_t from = 0, to = TRIG_MAX_ANGLE; animations[0] = ({ PropertyAnimation *property_animation = property_animation_create(&property_animation_implementation_stroke_start, layer, NULL, NULL); property_animation_from(property_animation, &from, sizeof(from), true); property_animation_to(property_animation, &to, sizeof(to), true); Animation *animation = (Animation *)property_animation; animation_set_custom_curve(animation, stroke_start_custom_curve); animation_set_delay(animation, duration * 2 / 3); animation_set_duration(animation, duration); animation_set_play_count(animation, ANIMATION_PLAY_COUNT_INFINITE); animation; });