Skip to content

Commit

Permalink
Removed the cross-fade when swapping language.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keflon committed Nov 1, 2023
1 parent 43b722c commit 88646a4
Showing 1 changed file with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ public BaseLanguageExtension()
{
}
public TEnum TextId { get; set; }
public bool ShowOff { get; set; }
private string _text;


public string Text
{
get => _text;
Expand Down Expand Up @@ -56,24 +58,6 @@ object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
public static readonly BindableProperty LookupProperty =
BindableProperty.CreateAttached("Lookup", typeof(string[]), typeof(Element), new string[] { "Hello", "World" }, BindingMode.OneWay, null, LookupPropertyChanged);

#if NORMAL
private static void LookupPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var langHost = GetLangHost(bindable);
string[] lookup = GetLookup(bindable);
//string[] lookup = (string[])newValue;
if(lookup != null)
{
string to = "???";
if(lookup.Length > (int)langHost.TextId)
{
to = lookup[(int)langHost.TextId];
}
langHost.Text = GetLookup(bindable)[(int)langHost.TextId];
}
}

#else
private static void LookupPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var langHost = GetLangHost(bindable);
Expand All @@ -86,7 +70,11 @@ private static void LookupPropertyChanged(BindableObject bindable, object oldVal
{
to = lookup[(int)(object)langHost.TextId];
}
CrossFadeText(langHost, to);
if (langHost.ShowOff)
CrossFadeText(langHost, to);
else
langHost.Text = GetLookup(bindable)[(int)(object)langHost.TextId];

}
}

Expand All @@ -109,7 +97,7 @@ private static async void CrossFadeText(BaseLanguageExtension<TEnum> langHost, s
await Task.Delay(16);
}
}
#endif

public static string[] GetLookup(BindableObject view)
{
var retval = (string[])view.GetValue(LookupProperty);
Expand Down

0 comments on commit 88646a4

Please sign in to comment.