Skip to main content

TextMagnifier

Struct TextMagnifier 

Source
pub struct TextMagnifier {
    pub key: Option<KeyRef>,
    pub magnifier_info: Ref<ValueNotifier<MagnifierInfo>>,
}
Expand description

A Magnifier positioned by rules dictated by the native Android magnifier.

The positioning rules are based on magnifier_info, as follows:

  • The loupe tracks the gesture’s x coordinate, clamping to the beginning and end of the currently editing line.

  • The focal point never contains anything out of the bounds of the text field or other widget being magnified (the MagnifierInfo::field_bounds).

  • The focal point always remains aligned with the y coordinate of the touch.

  • The loupe always remains on the screen.

  • When the line targeted by the touch’s y coordinate changes, the position is animated over JUMP_BETWEEN_LINES_ANIMATION_DURATION.

This behavior was based on the Android 12 source code, where possible, and on eyeballing a Pixel 6 running Android 12 otherwise.

Fields§

§key: Option<KeyRef>§magnifier_info: Ref<ValueNotifier<MagnifierInfo>>

The current status of the user’s touch.

As the value of the magnifier_info changes, the position of the loupe is adjusted automatically, according to the rules described in the TextMagnifier class description.

Implementations§

Source§

impl TextMagnifier

Source

pub const JUMP_BETWEEN_LINES_ANIMATION_DURATION: Duration

The duration that the position is animated if TextMagnifier just switched between lines.

Source

pub fn new(magnifier_info: Ref<ValueNotifier<MagnifierInfo>>) -> TextMagnifier

Creates a TextMagnifier.

The magnifier_info must be provided, and must be updated with new values as the user’s touch changes.

Source

pub fn key(self, key: KeyRef) -> TextMagnifier

Dart TextMagnifier(key:).

Source

pub fn adaptive_magnifier_configuration(app: &App) -> TextMagnifierConfiguration

Dart’s adaptiveMagnifierConfiguration: a TextMagnifierConfiguration that returns a CupertinoTextMagnifier on iOS, TextMagnifier on Android, and None on all other platforms, and shows the editing handles only on iOS.

Every call returns a configuration with the same builder, so two of them are the same configuration to a widget that compares them.

Trait Implementations§

Source§

impl Debug for TextMagnifier

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StatefulWidget for TextMagnifier

Source§

type State = TextMagnifierState

The state this widget creates.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn create_state(&self) -> TextMagnifierState

Creates the mutable state for this widget at a given location in the tree. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s debugFillProperties: the properties a dump shows for this widget, in Dart’s order. Dart’s Widget base only sets the dense tree style, which the framework does.
Source§

fn debug_check_constructor(&self)

Source§

fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>

Source§

fn type_name(&self) -> &'static str

See Widget::type_name. A stateful form another widget kind becomes (an animated or status transition widget) names the widget it wraps.

Auto Trait Implementations§

§

impl !RefUnwindSafe for TextMagnifier

§

impl !Send for TextMagnifier

§

impl !Sync for TextMagnifier

§

impl !UnwindSafe for TextMagnifier

§

impl Forget for TextMagnifier

§

impl Freeze for TextMagnifier
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, NonZero<u32>: Freeze, PhantomData<fn() -> ValueNotifier<MagnifierInfo>>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze,

§

impl Move for TextMagnifier

§

impl Unpin for TextMagnifier
where Rc<dyn Key>: Unpin, NonZero<u32>: Unpin, Rc<Keep>: Unpin,

§

impl UnsafeUnpin for TextMagnifier
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, PhantomData<fn() -> ValueNotifier<MagnifierInfo>>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<StatefulKind> for W
where W: StatefulWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>