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

Commit

Permalink
- rc3 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen committed Mar 30, 2020
1 parent 273da58 commit 9add9df
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 63 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 @@ -26,7 +26,7 @@
</group>
<group targetFramework="MonoAndroid10.0">
<dependency id="Xamarin.AndroidX.Lifecycle.LiveData" version="2.1.0" />
<dependency id="Xamarin.Google.Android.Material" version="1.1.0-rc2" />
<dependency id="Xamarin.Google.Android.Material" version="1.1.0-rc3" />
</group>
<group targetFramework="Xamarin.iOS10">
<dependency id="Xamarin.iOS.MaterialComponents" version="72.2.0.1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ScrollView>
<StackLayout Spacing="20" Padding="10">

<Label Text="Activity Indicators" FontSize="Large" />
<!--<Label Text="Activity Indicators" FontSize="Large" />
<Label Text="Default" Margin="0,0,0,-10" />
<StackLayout Orientation="Horizontal">
Expand Down Expand Up @@ -178,7 +178,7 @@
TextColor="{StaticResource SecondaryTextColor}" FontSize="14" />
<Button Text="more" HorizontalOptions="End" BackgroundColor="{StaticResource PrimaryColor}" />
</StackLayout>
</Frame>
</Frame>-->


<Label Text="Entries" FontSize="Large" />
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.Controls/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public App()
{
_testCloudService = DependencyService.Get<ITestCloudService>();

SetMainPage(CreateDefaultMainPage());
SetMainPage(new VisualGallery());

//TestMainPageSwitches();

Expand Down
54 changes: 0 additions & 54 deletions Xamarin.Forms.Material.Android/MaterialFormsEditTextManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,66 +12,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);
}
}
}
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>
1 change: 0 additions & 1 deletion Xamarin.Forms.Material.Android/Resources/values/styles.xml
Original file line number Diff line number Diff line change
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

0 comments on commit 9add9df

Please sign in to comment.