xamarin / XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.
MIT License
1.58k stars 471 forks source link

[Converter] Implement IsInRangeConverter #1159

Open GUOLDEV opened 3 years ago

GUOLDEV commented 3 years ago

Summary

I would like to implement a new converter IsInRangeConverter, that returns true or false checking if the passed value is between a minValue and maxValue, it can be a DateTime, Int, Double, etc. It can be any IComparable type.

I have created a PR just to exemplify the concept and added UnitTests to give a better idea of how it is going to work.

API Changes

NA

Intended Use Case

  1. It can be used to change font color based on an entry value within a range.

image

  1. It can be used to change the background color of dates within a range.

image

Who Will Do The Work?

AndreiMisiukevich commented 3 years ago

IsInRangeConverter?

GUOLDEV commented 3 years ago

@AndreiMisiukevich great name idea! I like that.

GUOLDEV commented 3 years ago

If we need type-specific converters, it can be, for example, IsDateTimeInRangeConverter...

AndreiMisiukevich commented 3 years ago

I guess a single converter can be implemented for all IComparable types

GUOLDEV commented 3 years ago

@AndreiMisiukevich @jfversluis I have created a PR for this issue, once it is approved I will finalize the missing parts, such as documentation, etc.