Else not needed on if - return pattern

This commit is contained in:
Depechie 2016-12-31 12:30:17 +01:00
Родитель 497a763303
Коммит b7268452d5
12 изменённых файлов: 80 добавлений и 99 удалений

Просмотреть файл

@ -21,29 +21,25 @@ namespace FormsCommunityToolkit.Effects.Droid
var editText = Control as EditText; var editText = Control as EditText;
if (editText == null) if (editText == null)
return; return;
else
{
old = editText.InputType;
oldFilters = editText.GetFilters().ToArray();
editText.SetRawInputType(InputTypes.ClassText | InputTypes.TextFlagCapCharacters); old = editText.InputType;
oldFilters = editText.GetFilters().ToArray();
var newFilters = oldFilters.ToList(); editText.SetRawInputType(InputTypes.ClassText | InputTypes.TextFlagCapCharacters);
newFilters.Add(new InputFilterAllCaps());
editText.SetFilters(newFilters.ToArray()); var newFilters = oldFilters.ToList();
} newFilters.Add(new InputFilterAllCaps());
} editText.SetFilters(newFilters.ToArray());
}
protected override void OnDetached() protected override void OnDetached()
{ {
var editText = Control as EditText; var editText = Control as EditText;
if (editText == null) if (editText == null)
return; return;
else
{ editText.SetRawInputType(old);
editText.SetRawInputType(old); editText.SetFilters(oldFilters);
editText.SetFilters(oldFilters); }
}
}
} }
} }

Просмотреть файл

@ -21,7 +21,6 @@ namespace FormsCommunityToolkit.Effects.Droid
var effect = (FormsCommunityToolkit.Effects.CustomFontEffect)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.CustomFontEffect); var effect = (FormsCommunityToolkit.Effects.CustomFontEffect)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.CustomFontEffect);
if (effect != null && !string.IsNullOrWhiteSpace(effect.FontPath)) if (effect != null && !string.IsNullOrWhiteSpace(effect.FontPath))
{ {
var font = Typeface.CreateFromAsset(Forms.Context.Assets, effect.FontPath); var font = Typeface.CreateFromAsset(Forms.Context.Assets, effect.FontPath);
control.Typeface = font; control.Typeface = font;
} }

Просмотреть файл

@ -16,7 +16,8 @@ namespace FormsCommunityToolkit.Effects.Droid
protected override void OnAttached() protected override void OnAttached()
{ {
var editText = Control as EditText; var editText = Control as EditText;
if (editText == null) return; if (editText == null)
return;
old = editText.InputType; old = editText.InputType;
editText.InputType = editText.InputType | Android.Text.InputTypes.TextFlagNoSuggestions; editText.InputType = editText.InputType | Android.Text.InputTypes.TextFlagNoSuggestions;
@ -25,7 +26,8 @@ namespace FormsCommunityToolkit.Effects.Droid
protected override void OnDetached() protected override void OnDetached()
{ {
var editText = Control as EditText; var editText = Control as EditText;
if (editText == null) return; if (editText == null)
return;
editText.InputType = old; editText.InputType = old;
} }

Просмотреть файл

@ -15,16 +15,14 @@ namespace FormsCommunityToolkit.Effects.Droid
if (control == null) if (control == null)
return; return;
else
{ var effect = (FormsCommunityToolkit.Effects.MultiLineLabelEffect)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.MultiLineLabelEffect);
var effect = (FormsCommunityToolkit.Effects.MultiLineLabelEffect)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.MultiLineLabelEffect); if (effect != null && effect.Lines > 0)
if (effect != null && effect.Lines > 0) {
{ control.SetSingleLine(false);
control.SetSingleLine(false); control.SetLines(effect.Lines);
control.SetLines(effect.Lines); }
} }
}
}
protected override void OnDetached() protected override void OnDetached()
{ {

Просмотреть файл

@ -19,8 +19,8 @@ namespace FormsCommunityToolkit.Effects.Droid
var editText = Control as EditText; var editText = Control as EditText;
if (editText == null) if (editText == null)
return; return;
else
editText.SetSelectAllOnFocus(true); editText.SetSelectAllOnFocus(true);
} }
protected override void OnDetached() protected override void OnDetached()
@ -28,8 +28,8 @@ namespace FormsCommunityToolkit.Effects.Droid
var editText = Control as EditText; var editText = Control as EditText;
if (editText == null) if (editText == null)
return; return;
else
editText.SetSelectAllOnFocus(false); editText.SetSelectAllOnFocus(false);
} }
} }
} }

Просмотреть файл

@ -62,17 +62,17 @@ namespace FormsCommunityToolkit.Effects.Droid
var textView = Control as TextView; var textView = Control as TextView;
if (textView == null) if (textView == null)
return; return;
else
textView.AddOnLayoutChangeListener(_listener = new ShrinkTextOnLayoutChangeListener(textView)); textView.AddOnLayoutChangeListener(_listener = new ShrinkTextOnLayoutChangeListener(textView));
} }
protected override void OnDetached() protected override void OnDetached()
{ {
var textView = Control as TextView; var textView = Control as TextView;
if (textView == null) if (textView == null)
return; return;
else
textView.RemoveOnLayoutChangeListener(_listener); textView.RemoveOnLayoutChangeListener(_listener);
} }
} }
} }

Просмотреть файл

@ -18,11 +18,9 @@ namespace FormsCommunityToolkit.Effects.iOS
var editText = Control as UITextField; var editText = Control as UITextField;
if (editText == null) if (editText == null)
return; return;
else
{ old = editText.AutocapitalizationType;
old = editText.AutocapitalizationType; editText.AutocapitalizationType = UITextAutocapitalizationType.AllCharacters;
editText.AutocapitalizationType = UITextAutocapitalizationType.AllCharacters;
}
} }
protected override void OnDetached() protected override void OnDetached()
@ -30,8 +28,8 @@ namespace FormsCommunityToolkit.Effects.iOS
var editText = Control as UITextField; var editText = Control as UITextField;
if (editText == null) if (editText == null)
return; return;
else
editText.AutocapitalizationType = old; editText.AutocapitalizationType = old;
} }
} }
} }

Просмотреть файл

@ -13,15 +13,13 @@ namespace FormsCommunityToolkit.Effects.iOS
{ {
var control = Control as UILabel; var control = Control as UILabel;
if (control == null) if (control == null)
return; return;
else
{ var effect = (FormsCommunityToolkit.Effects.CustomFontEffect)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.CustomFontEffect);
var effect = (FormsCommunityToolkit.Effects.CustomFontEffect)Element.Effects.FirstOrDefault (item => item is FormsCommunityToolkit.Effects.CustomFontEffect); if (effect != null && !string.IsNullOrWhiteSpace(effect.FontPath))
if (effect != null && !string.IsNullOrWhiteSpace (effect.FontPath)) control.Font = UIFont.FromName(effect.FontFamilyName, control.Font.PointSize);
control.Font = UIFont.FromName (effect.FontFamilyName, control.Font.PointSize); }
}
}
protected override void OnDetached () protected override void OnDetached ()
{ {

Просмотреть файл

@ -18,21 +18,19 @@ namespace FormsCommunityToolkit.Effects.iOS
var entry = Control as UITextField; var entry = Control as UITextField;
if (entry == null || string.IsNullOrWhiteSpace(entry.Placeholder)) if (entry == null || string.IsNullOrWhiteSpace(entry.Placeholder))
return; return;
else
{ old = entry.AttributedPlaceholder;
old = entry.AttributedPlaceholder; var entryFontSize = entry.Font.PointSize;
var entryFontSize = entry.Font.PointSize; entry.AttributedPlaceholder = new NSAttributedString(entry.Placeholder, font: UIFont.ItalicSystemFontOfSize(entryFontSize));
entry.AttributedPlaceholder = new NSAttributedString(entry.Placeholder, font: UIFont.ItalicSystemFontOfSize(entryFontSize)); }
}
}
protected override void OnDetached() protected override void OnDetached()
{ {
var entry = Control as UITextField; var entry = Control as UITextField;
if (entry == null) if (entry == null)
return; return;
else
entry.AttributedPlaceholder = old; entry.AttributedPlaceholder = old;
} }
} }
} }

Просмотреть файл

@ -18,15 +18,13 @@ namespace FormsCommunityToolkit.Effects.iOS
if (control == null) if (control == null)
return; return;
else
{
initialeLines = control.Lines;
var effect = (FormsCommunityToolkit.Effects.MultiLineLabelEffect)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.MultiLineLabelEffect); initialeLines = control.Lines;
if (effect != null && effect.Lines > 0)
control.Lines = effect.Lines; var effect = (FormsCommunityToolkit.Effects.MultiLineLabelEffect)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.MultiLineLabelEffect);
} if (effect != null && effect.Lines > 0)
} control.Lines = effect.Lines;
}
protected override void OnDetached() protected override void OnDetached()
{ {
@ -34,8 +32,8 @@ namespace FormsCommunityToolkit.Effects.iOS
if (control == null) if (control == null)
return; return;
else
control.Lines = initialeLines; control.Lines = initialeLines;
} }
} }
} }

Просмотреть файл

@ -18,11 +18,9 @@ namespace FormsCommunityToolkit.Effects.iOS
var editText = Control as UITextField; var editText = Control as UITextField;
if (editText == null) if (editText == null)
return; return;
else
{ old = editText.BorderStyle;
old = editText.BorderStyle; editText.BorderStyle = UITextBorderStyle.None;
editText.BorderStyle = UITextBorderStyle.None;
}
} }
protected override void OnDetached() protected override void OnDetached()
@ -30,8 +28,8 @@ namespace FormsCommunityToolkit.Effects.iOS
var editText = Control as UITextField; var editText = Control as UITextField;
if (editText == null) if (editText == null)
return; return;
else
editText.BorderStyle = old; editText.BorderStyle = old;
} }
} }
} }

Просмотреть файл

@ -18,27 +18,23 @@ namespace FormsCommunityToolkit.Effects.iOS
var editText = Control as UITextField; var editText = Control as UITextField;
if (editText == null) if (editText == null)
return; return;
else
{ editText.EditingDidBegin += (object sender, System.EventArgs e) =>
editText.EditingDidBegin += (object sender, System.EventArgs e) => {
{ editText.PerformSelector(new Selector("selectAll"), null, 0.0f);
editText.PerformSelector(new Selector("selectAll"), null, 0.0f); };
}; }
}
}
protected override void OnDetached() protected override void OnDetached()
{ {
var editText = Control as UITextField; var editText = Control as UITextField;
if (editText == null) if (editText == null)
return; return;
else
{ ßeditText.EditingDidBegin -= (object sender, System.EventArgs e) =>
editText.EditingDidBegin -= (object sender, System.EventArgs e) => {
{ editText.PerformSelector(new Selector("selectAll"), null, 0.0f);
editText.PerformSelector(new Selector("selectAll"), null, 0.0f); };
}; }
}
}
} }
} }