dotMorten / MauiEx

A set of .NET MAUI controls
Apache License 2.0
224 stars 55 forks source link

AutoSuggestBox: Add text visual properties #2

Open dotMorten opened 6 years ago

dotMorten commented 6 years ago
public class AutoSuggestBox
{
     public Xamarin.Forms.Color PlaceholderTextColor { get; set; } // Completed
     public Xamarin.Forms.Color TextColor { get; set; } // Completed
     [Xamarin.Forms.TypeConverter(typeof(Xamarin.Forms.FontSizeConverter))]
     public double FontSize { get; set; } // TODO
     public string FontFamily { get; set; } // TODO
}
dotMorten commented 6 years ago

Useful reference implementations. FontFamily/FontSize: https://github.com/xamarin/Xamarin.Forms/blob/ffa53d31137b61e34192521cc10aae5c151d0c98/Xamarin.Forms.Platform.UAP/EntryRenderer.cs#L149-L181

TextColor: https://github.com/xamarin/Xamarin.Forms/blob/ffa53d31137b61e34192521cc10aae5c151d0c98/Xamarin.Forms.Platform.UAP/EntryRenderer.cs#L233-L242

PlaceHolderTextColor: https://github.com/xamarin/Xamarin.Forms/blob/ffa53d31137b61e34192521cc10aae5c151d0c98/Xamarin.Forms.Platform.UAP/EntryRenderer.cs#L217-L226

SaiRama72 commented 6 years ago

dotMorten, How to change border and Text color for this control? Thanks,

dotMorten commented 6 years ago

Set the TextColor property. Note this property isn't in the released version yet so you need to build the library yourself from the master branch

dotMorten commented 6 years ago

...there are no border property at this point

SaiRama72 commented 6 years ago

dotMorten, Can you please refer this link? https://github.com/dotMorten/XamarinFormsControls/tree/master/AutoSuggestBox

As they mentioned UWP : Black Color Theme Android : White Color Theme IOS : White With Line separator Theme

I'm currently running on Android mobile still getting Balck color Theme only. Any suggestions why I'm getting like this?

Thanks,

dotMorten commented 5 years ago

TextColor and PlaceholderTextColor added.

breyed commented 5 years ago

One approach to supporting visual overrides is to inherent from Entry. You may not use its renderer, depending on the platform, but it will give you all the visual properties in a way that is familiar to Xamarin developers.

dotMorten commented 5 years ago

Entry's native element doesn't support drop-down on all platforms.

breyed commented 5 years ago

Understood. On those platforms, you'll need to replace the renderer used by Entry with your renderer that uses native elements that do support drop-down. However, by deriving from Entry, your renderer will have access to all of Entry's properties for formatting the native elements.

dotMorten commented 5 years ago

That won't really help. All I would save would be writing the properties which is trivial. It's hooking them up to the native elements that are less so. And even worse I'd inherit properties in not interested in implementing. In any case the goal of the control is to port AutoSuggestBox to Forms and follow it's object model (which isn't inheriting from TextBox if I recall correctly)

breyed commented 5 years ago

From a usage perspective, an app's styles and helpers designed to work with Entry would continue to work. There may also be opportunity to use parts of the Entrys renders (through I haven't checked), which may help with the properties that may be of less interest but still enough that Entry included them.

Basing the design on a single native control, rather than an abstract UI concept, differs from the typical Xamarin.Forms approach, and could box in the design of the control long term. Ironically, the abstract design approach stated in the project readme does use an abstract UI concept, completely in line with Xamarin.Forms design principles:

Represents a text control that makes suggestions to users as they type. The app is notified when text has been changed by the user and is responsible for providing relevant suggestions for this control to display.

dotMorten commented 5 years ago

basing the design on a single native control, rather than an abstract UI concept

It's where I think XF went down the wrong path, and this being my repo I'm free to choose the pattern I find right.

Also it's a breaking change I'm not up for making

federicojoselucia commented 4 years ago

Hi, is there any update on FontSize property?