Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Bump to Material 1.1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen committed Dec 11, 2020
1 parent 2607556 commit 8054fe0
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .nuspec/Xamarin.Forms.Visual.Material.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<group targetFramework="MonoAndroid10.0">
<dependency id="Xamarin.AndroidX.Lifecycle.LiveData" version="2.2.0.3" />
<dependency id="Xamarin.Google.Android.Material" version="1.0.0.1" />
<dependency id="Xamarin.Google.Android.Material" version="1.1.0.5" />
</group>
<group targetFramework="Xamarin.iOS10">
<dependency id="Xamarin.iOS.MaterialComponents" version="92.0.0"/>
Expand Down
2 changes: 1 addition & 1 deletion .nuspec/Xamarin.Forms.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<dependencies>
<group targetFramework="MonoAndroid10.0">
<dependency id="Xamarin.AndroidX.Lifecycle.LiveData" version="2.2.0.3" />
<dependency id="Xamarin.Google.Android.Material" version="1.0.0.1" />
<dependency id="Xamarin.Google.Android.Material" version="1.1.0.5" />
<dependency id="Xamarin.AndroidX.Legacy.Support.V4" version="1.0.0.5" />
<dependency id="Xamarin.AndroidX.Browser" version="1.0.0.1" />
</group>
Expand Down
2 changes: 1 addition & 1 deletion DualScreen/DualScreen.Android/DualScreen.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.2.0.3" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.1.0.5" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.5" />
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions EmbeddingTestBeds/Embedding.Droid/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PackageReference Include="Xamarin.AndroidX.Browser" Version="1.0.0.1" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.1" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.1.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.1.0.5" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.1" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ItemGroup Condition="'$(TargetFramework)' == 'MonoAndroid10.0'">
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.2.0.3" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.5" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.1.0.5" />
<PackageReference Include="Xamarin.AndroidX.RecyclerView" Version="1.1.0.5" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.2.0.3" />
<PackageReference Include="Xamarin.AndroidX.Browser" Version="1.2.0.2" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.1.0.5" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.5" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.5" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Xamarin.Forms.ControlGallery.Android/Nuget.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.1.0" />
<PackageReference Include="Xamarin.AndroidX.Browser" Version="1.0.0" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.1.0.5" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0" />
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion Xamarin.Forms.DualScreen/Xamarin.Forms.DualScreen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'MonoAndroid10.0'">
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.2.0.3" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.1.0.5" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.5" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.2.0.3" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.1.0.5" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.5" />
<PackageReference Include="Xamarin.GooglePlayServices.Maps" Version="117.0.0" />
</ItemGroup>
Expand Down
26 changes: 13 additions & 13 deletions Xamarin.Forms.Material.Android/MaterialColors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,27 @@ public static PlatformColor CreateEntryFilledInputBackgroundColor(Color backgrou

public static (PlatformColor InlineColor, PlatformColor FloatingColor) GetPlaceHolderColor(Color placeholderColor, Color textColor)
{
PlatformColor color;
PlatformColor inlineColor;
PlatformColor floatingColor;
float inlineAlpha = kFilledTextFieldOnSurfaceAlpha + kFilledPlaceHolderOffset;

if (placeholderColor == Color.Default)
{
if (textColor == Color.Default)
color = MaterialColors.Light.OnSurfaceColor;
else
color = ToPlatformColor(textColor);
inlineColor = WithAlpha(MaterialColors.Light.OnSurfaceColor, inlineAlpha);
floatingColor = MaterialColors.Light.PrimaryColor;
}
else
color = ToPlatformColor(placeholderColor);

var inlineColor = WithAlpha(color, kFilledTextFieldOnSurfaceAlpha + kFilledPlaceHolderOffset);
var floatingColor = WithAlpha(color, kFilledTextFieldActiveAlpha + kFilledPlaceHolderOffset);
{
inlineColor = WithAlpha(ToPlatformColor(placeholderColor), inlineAlpha);
floatingColor = ToPlatformColor(placeholderColor);
}

return (inlineColor, floatingColor);
}

public static (PlatformColor FocusedColor, PlatformColor UnFocusedColor) GetUnderlineColor(Color textColor)
public static (PlatformColor FocusedColor, PlatformColor UnFocusedColor) GetUnderlineColor(Color placeholderColor)
{
PlatformColor color = GetEntryTextColor(textColor);
PlatformColor color = GetEntryTextColor(placeholderColor);
return (color, WithAlpha(color, kFilledTextFieldIndicatorLineAlpha));
}

Expand Down Expand Up @@ -174,11 +174,11 @@ public static ColorStateList CreateEntryFilledPlaceholderColors(PlatformColor in
{
int[][] States =
{
new []{ global::Android.Resource.Attribute.StateEnabled, global::Android.Resource.Attribute.StatePressed },
new []{ ~global::Android.Resource.Attribute.StateEnabled },
new int[0] { }
};

var colors = new int[] { floatingColor, inlineColor };
var colors = new int[] { inlineColor, floatingColor };
return new ColorStateList(States, colors);
}

Expand Down
1 change: 0 additions & 1 deletion Xamarin.Forms.Material.Android/MaterialEntryRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ protected override MaterialFormsTextInputLayout CreateNativeControl()
var view = inflater.Inflate(Resource.Layout.TextInputLayoutFilledBox, null);
_textInputLayout = (MaterialFormsTextInputLayout)view;
_textInputEditText = _textInputLayout.FindViewById<MaterialFormsEditText>(Resource.Id.materialformsedittext);

return _textInputLayout;
}

Expand Down
56 changes: 1 addition & 55 deletions Xamarin.Forms.Material.Android/MaterialFormsEditTextManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,66 +8,12 @@ namespace Xamarin.Forms.Material.Android
{
internal static class MaterialFormsEditTextManager
{
// These paddings are a hack to center the hint
// once this issue is resolved we can get rid of these paddings
// https://github.com/material-components/material-components-android/issues/120
// https://stackoverflow.com/questions/50487871/how-to-make-the-hint-text-of-textinputlayout-vertically-center

static Thickness _centeredText = new Thickness(16, 8, 12, 27);
static Thickness _alignedWithUnderlineText = new Thickness(16, 20, 12, 16);

public static void Init(TextInputEditText textInputEditText)
{
textInputEditText.TextChanged += OnTextChanged;
textInputEditText.FocusChange += OnFocusChanged;
}

public static void Dispose(TextInputEditText textInputEditText)
{
textInputEditText.TextChanged -= OnTextChanged;
textInputEditText.FocusChange -= OnFocusChanged;
}

private static void OnFocusChanged(object sender, global::Android.Views.View.FocusChangeEventArgs e)
{
if (sender is TextInputEditText textInputEditText)
{
// Delay padding update until after the keyboard has showed up otherwise updating the padding
// stops the keyboard from showing up
// TODO closure
if (e.HasFocus)
Device.BeginInvokeOnMainThread(() => UpdatePadding(textInputEditText));
else
UpdatePadding(textInputEditText);
}
}

private static void OnTextChanged(object sender, global::Android.Text.TextChangedEventArgs e)
{
if (e.BeforeCount == 0 || e.AfterCount == 0)
UpdatePadding(sender as TextInputEditText);
}

static void UpdatePadding(TextInputEditText textInputEditText)
{
Thickness rect = _centeredText;

if (!String.IsNullOrWhiteSpace(textInputEditText.Text) || textInputEditText.HasFocus)
{
rect = _alignedWithUnderlineText;
}

Context Context = textInputEditText.Context;
var left = (int)Context.ToPixels(rect.Left);
var top = (int)Context.ToPixels(rect.Top);
var right = (int)Context.ToPixels(rect.Right);
var bottom = (int)Context.ToPixels(rect.Bottom);

if (textInputEditText.PaddingLeft != left ||
textInputEditText.PaddingTop != top ||
textInputEditText.PaddingRight != right ||
textInputEditText.PaddingBottom != bottom)
textInputEditText.SetPadding(left, top, right, bottom);
}
}
}
}
32 changes: 8 additions & 24 deletions Xamarin.Forms.Material.Android/MaterialFormsTextInputLayoutBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ public class MaterialFormsTextInputLayoutBase : TextInputLayout
Color _formsTextColor;
Color _formsPlaceholderColor;
bool _isSetup = false;
ColorStateList _focusedFilledColorList;
ColorStateList _unfocusedEmptyColorList;
private ColorStateList _unfocusedUnderlineColorsList;
private ColorStateList _focusedUnderlineColorsList;
ColorStateList _placeholderColorsList;

static readonly int[][] s_colorStates = { new[] { global::Android.Resource.Attribute.StateEnabled }, new[] { -global::Android.Resource.Attribute.StateEnabled } };
bool _disposed = false;

Expand All @@ -47,15 +45,8 @@ void ResetTextColors(Color formsTextColor, Color formsPlaceHolderColor)

var underlineColors = MaterialColors.GetUnderlineColor(_formsPlaceholderColor);
var placeHolderColors = MaterialColors.GetPlaceHolderColor(_formsPlaceholderColor, _formsTextColor);
_placeholderColorsList = MaterialColors.CreateEntryFilledPlaceholderColors(placeHolderColors.InlineColor, placeHolderColors.FloatingColor);

// I realize these are the same but I have to set it to a difference instance
// otherwise when focused it won't change to the color I want it to and it'll just think
// I'm not actually changing anything
_unfocusedUnderlineColorsList = MaterialColors.CreateEntryUnderlineColors(underlineColors.FocusedColor, underlineColors.UnFocusedColor);
_focusedUnderlineColorsList = MaterialColors.CreateEntryUnderlineColors(underlineColors.FocusedColor, underlineColors.UnFocusedColor);

_focusedFilledColorList = MaterialColors.CreateEntryFilledPlaceholderColors(placeHolderColors.FloatingColor, placeHolderColors.FloatingColor);
_unfocusedEmptyColorList = MaterialColors.CreateEntryFilledPlaceholderColors(placeHolderColors.InlineColor, placeHolderColors.FloatingColor);

var textColor = MaterialColors.GetEntryTextColor(formsTextColor).ToArgb();
EditText.SetTextColor(new ColorStateList(s_colorStates, new[] { textColor, textColor }));
Expand All @@ -76,16 +67,9 @@ public virtual void ApplyTheme(Color formsTextColor, Color formsPlaceHolderColor
{
ResetTextColors(formsTextColor, formsPlaceHolderColor);
}

if (HasFocus)
ViewCompat.SetBackgroundTintList(EditText, _focusedUnderlineColorsList);
else
ViewCompat.SetBackgroundTintList(EditText, _unfocusedUnderlineColorsList);

if (HasFocus || !string.IsNullOrWhiteSpace(EditText.Text))
this.DefaultHintTextColor = _focusedFilledColorList;
else
this.DefaultHintTextColor = _unfocusedEmptyColorList;
this.DefaultHintTextColor = _placeholderColorsList;
this.HintTextColor = _placeholderColorsList.ToDefaultOnlyColorStateList();
this.BoxStrokeColor = _placeholderColorsList.DefaultColor;
}

void ApplyTheme() => ApplyTheme(_formsTextColor, _formsPlaceholderColor);
Expand Down Expand Up @@ -119,7 +103,7 @@ public virtual void SetHint(string hint, VisualElement element)
Hint = hint;
// EditText.Hint => Hint
// It is impossible to reset it but you can make it invisible.
EditText.SetHintTextColor(global::Android.Graphics.Color.Transparent);
//EditText.SetHintTextColor(global::Android.Graphics.Color.Transparent);
}
}

Expand All @@ -146,4 +130,4 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
<xamarin.forms.material.android.MaterialPickerEditText
android:id="@+id/materialformsedittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-7dp"/>
android:layout_height="wrap_content" />
</xamarin.forms.material.android.MaterialPickerTextInputLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
<xamarin.forms.material.android.MaterialFormsEditText
android:id="@+id/materialformsedittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-7dp" />
android:layout_height="wrap_content" />
</xamarin.forms.material.android.MaterialFormsTextInputLayout>
3 changes: 1 addition & 2 deletions Xamarin.Forms.Material.Android/Resources/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<attr name="materialProgressBarCircularStyle" format="reference" />
<attr name="materialCheckBoxStyle" format="reference" />
<!-- Material Base Theme -->
<style name="XamarinFormsMaterialTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<style name="XamarinFormsMaterialTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="materialButtonStyle">@style/XamarinFormsMaterialButton</item>
<item name="materialOutlinedButtonStyle">@style/XamarinFormsMaterialButtonOutlined</item>
<item name="materialSliderStyle">@style/XamarinFormsMaterialSlider</item>
Expand Down Expand Up @@ -40,7 +40,6 @@
<item name="android:paddingBottom">8dp</item>
</style>
<style name="XamarinFormsMaterialEntryFilled" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
<item name="boxCollapsedPaddingTop">8dp</item>
</style>
<!-- Material Checkbox -->
<style name="Widget.MaterialComponents.CompoundButton.CheckBox" parent="Widget.AppCompat.CompoundButton.CheckBox">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<ItemGroup>
<AndroidResource Include="Resources\**\*" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'MonoAndroid10.0'">
<ItemGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) " >
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.2.0.3" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.1.0.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Xamarin.Forms.Core\Xamarin.Forms.Core.csproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.2.0.3" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.1.0.5" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.5" />
</ItemGroup>
<ItemGroup>
Expand All @@ -56,4 +56,4 @@
<ItemGroup>
<Folder Include="Shapes\" />
</ItemGroup>
</Project>
</Project>

0 comments on commit 8054fe0

Please sign in to comment.