зеркало из https://github.com/DeGsoft/maui-linux.git
Centralize Theme Wrapper and fix sandbox to work with previewer (#5495)
* Centralize Theme Wrapper and fix sandbox to work with previewer * simplify * Update Xamarin.Forms.Material.Android/MaterialContextThemeWrapper.cs Co-Authored-By: PureWeen <shane94@hotmail.com> * Update Xamarin.Forms.Material.Android/MaterialContextThemeWrapper.cs Co-Authored-By: PureWeen <shane94@hotmail.com> * Update Xamarin.Forms.Material.Android/MaterialContextThemeWrapper.cs
This commit is contained in:
Родитель
6a3a10afea
Коммит
808f2f638e
|
@ -69,6 +69,9 @@
|
|||
<Label Text="Custom" Margin="0,0,0,-10" />
|
||||
<ProgressBar Progress="0.5" ProgressColor="{StaticResource PrimaryColor}" BackgroundColor="{StaticResource SecondaryColor}" />
|
||||
|
||||
<Label Text="Height 20" Margin="0,0,0,-10" />
|
||||
<ProgressBar Progress="0.5" HeightRequest="20" ProgressColor="{StaticResource PrimaryColor}" BackgroundColor="{StaticResource SecondaryColor}" />
|
||||
|
||||
|
||||
<Label Text="Buttons" FontSize="Large" />
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
public MaterialActivityIndicatorRenderer(Context context)
|
||||
: base(context)
|
||||
{
|
||||
_control = new CircularProgress(new ContextThemeWrapper(context, Resource.Style.XamarinFormsMaterialProgressBarCircular), null, Resource.Style.XamarinFormsMaterialProgressBarCircular)
|
||||
_control = new CircularProgress(MaterialContextThemeWrapper.Create(context), null, Resource.Attribute.materialProgressBarCircularStyle)
|
||||
{
|
||||
// limiting size to compare iOS realization
|
||||
// https://github.com/material-components/material-components-ios/blob/develop/components/ActivityIndicator/src/MDCActivityIndicator.m#L425
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
readonly AutomationPropertiesProvider _automationPropertiesProvider;
|
||||
|
||||
public MaterialButtonRenderer(Context context)
|
||||
: base(new ContextThemeWrapper(context, Resource.Style.XamarinFormsMaterialTheme))
|
||||
: base(MaterialContextThemeWrapper.Create(context))
|
||||
{
|
||||
_automationPropertiesProvider = new AutomationPropertiesProvider(this);
|
||||
_buttonLayoutManager = new ButtonLayoutManager(this,
|
||||
|
|
|
@ -2,23 +2,28 @@
|
|||
using Android.Content;
|
||||
using Android.Views;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
using AndroidAppCompat = Android.Support.V7.Content.Res.AppCompatResources;
|
||||
|
||||
namespace Xamarin.Forms.Material.Android
|
||||
{
|
||||
public class MaterialContextThemeWrapper : ContextThemeWrapper
|
||||
{
|
||||
public MaterialContextThemeWrapper(Context context) : base(context, Resource.Style.XamarinFormsMaterialTheme)
|
||||
public MaterialContextThemeWrapper(Context context) : this(context, Resource.Style.XamarinFormsMaterialTheme)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public static Context Create(Context context)
|
||||
MaterialContextThemeWrapper(Context context, int themeResId) : base(context, themeResId)
|
||||
{
|
||||
if (context is MaterialContextThemeWrapper)
|
||||
return context;
|
||||
|
||||
}
|
||||
|
||||
public static MaterialContextThemeWrapper Create(Context context)
|
||||
{
|
||||
if (context is MaterialContextThemeWrapper materialContext)
|
||||
return materialContext;
|
||||
|
||||
return new MaterialContextThemeWrapper(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
readonly MotionEventHelper _motionEventHelper;
|
||||
|
||||
public MaterialFrameRenderer(Context context)
|
||||
: base(new ContextThemeWrapper(context, Resource.Style.XamarinFormsMaterialTheme))
|
||||
: base(MaterialContextThemeWrapper.Create(context))
|
||||
{
|
||||
_gestureManager = new GestureManager(this);
|
||||
_effectControlProvider = new EffectControlProvider(this);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
MotionEventHelper _motionEventHelper;
|
||||
|
||||
public MaterialProgressBarRenderer(Context context)
|
||||
: base(new ContextThemeWrapper(context, Resource.Style.XamarinFormsMaterialProgressBarHorizontal), null, Resource.Style.XamarinFormsMaterialProgressBarHorizontal)
|
||||
: base(MaterialContextThemeWrapper.Create(context), null, Resource.Attribute.materialProgressBarHorizontalStyle)
|
||||
{
|
||||
Indeterminate = false;
|
||||
Max = MaximumValue;
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace Xamarin.Forms.Material.Android
|
|||
double _min = 0.0;
|
||||
|
||||
public MaterialSliderRenderer(Context context)
|
||||
: base(new ContextThemeWrapper(context, Resource.Style.XamarinFormsMaterialSlider), null, Resource.Style.XamarinFormsMaterialSlider)
|
||||
: base(MaterialContextThemeWrapper.Create(context), null, Resource.Attribute.materialSliderStyle)
|
||||
{
|
||||
SetOnSeekBarChangeListener(this);
|
||||
Max = (int)MaximumValue;
|
||||
|
|
|
@ -2,11 +2,17 @@
|
|||
<resources>
|
||||
|
||||
<attr name="materialOutlinedButtonStyle" format="reference"/>
|
||||
<attr name="materialSliderStyle" format="reference"/>
|
||||
<attr name="materialProgressBarHorizontalStyle" format="reference"/>
|
||||
<attr name="materialProgressBarCircularStyle" format="reference"/>
|
||||
|
||||
<!-- Material Base Theme -->
|
||||
<style name="XamarinFormsMaterialTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
|
||||
<item name="materialButtonStyle">@style/XamarinFormsMaterialButton</item>
|
||||
<item name="materialOutlinedButtonStyle">@style/XamarinFormsMaterialButtonOutlined</item>
|
||||
<item name="materialSliderStyle">@style/XamarinFormsMaterialSlider</item>
|
||||
<item name="materialProgressBarHorizontalStyle">@style/XamarinFormsMaterialProgressBarHorizontal</item>
|
||||
<item name="materialProgressBarCircularStyle">@style/XamarinFormsMaterialProgressBarCircular</item>
|
||||
</style>
|
||||
|
||||
<!-- Material Sliders -->
|
||||
|
|
Загрузка…
Ссылка в новой задаче