-
Notifications
You must be signed in to change notification settings - Fork 67
Add TextColor property to BaseButton and make MathInputButton's color customizable #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
cd3c5c7
Add TextColor property to BaseButton and make MathInputButton's color…
SymboLinker 083350f
Add a few ButtonTests and refactor out use-once functions from BaseBu…
SymboLinker 04abe53
Fix typo in unit test name MathInputButtonsHaveBlackTextColorByDefault
SymboLinker aa41a64
ButtonTests: use [ClassData] attribute, use NotNull<T>() extension, i…
SymboLinker 4a56307
Update CSharpMath.CrossPlatform.slnf (suggested commit))
SymboLinker 0271ae8
ButtonTests: use the [MemberData] attribute and MathKeyboardInput enu…
SymboLinker 6aa2ddd
Rename and move file from TestHelpers/NotNull.cs to /Extensions.cs
SymboLinker f00fa3a
Add ButtonBase.TextColorProperty Xaml Tests to CSharpMath.Forms.Tests
SymboLinker 99417ce
Add MathInputButton_Command unit test and do the suggested cleaning
SymboLinker fe0f460
MathInputButton_Command test: use the MathInputButton's Keyboard getter
SymboLinker 132e19f
MathInputButton_Command test: no variable is needed anymore for the M…
SymboLinker d3f7b93
Revert "MathInputButton_Command test: no variable is needed anymore f…
SymboLinker bca8b4d
Revert "MathInputButton_Command test: use the MathInputButton's Keybo…
SymboLinker 4223835
Add MathButton unit tests that check that the image color is correctl…
SymboLinker 8c486dd
Attempt/test 1: also reference SkiaSharp from the CSharpMath.Forms.cs…
SymboLinker 350fc9b
Attempt/test 2: also reference SkiaSharp from CSharpMath.Forms.Test.c…
SymboLinker b43a974
Attempt/test 3: Reference SkiaSharp & SkiaSharp.Views.Forms from test…
SymboLinker 6ccb10b
Revert "Attempt/test 3: Reference SkiaSharp & SkiaSharp.Views.Forms f…
SymboLinker fc639d4
Revert "Attempt/test 2: also reference SkiaSharp from CSharpMath.Form…
SymboLinker e009029
Revert "Attempt/test 1: also reference SkiaSharp from the CSharpMath.…
SymboLinker 31cc12a
Update SkiaSharp and SkiaSharp.View.Forms to 2.80.2 in all referencin…
SymboLinker 593d677
Add libSkiaSharp.dll to test project CSharpMath.Forms.Tests
SymboLinker ae84658
Revert "Add libSkiaSharp.dll to test project CSharpMath.Forms.Tests"
SymboLinker e2dc966
Revert "Update SkiaSharp and SkiaSharp.View.Forms to 2.80.2 in all re…
SymboLinker 1a05de8
Customize buttons for MathKeyboardInput even more
SymboLinker 1991402
Make blinking Placeholder's Nucleus and ForeColor customizable in bot…
SymboLinker ddb5e4e
MathInputButtons with customized placeholders: what you see is what y…
SymboLinker a3e6838
Merge pull request #2 from verybadcat/master
SymboLinker 0047a83
Correct comment
SymboLinker d58072c
MathInputButton: only perform the placeholder color logic if defaults…
SymboLinker 2a9951c
Merge pull request #4 from verybadcat/master
SymboLinker 7ee69ff
Comment out 2 ButtonTests that have Linux failures
SymboLinker 3bb9e34
Use FactAttribute.Skip
SymboLinker da8b291
Delete NullableColorBindablePropertyHelper (I am afraid I did not try…
SymboLinker a8c6f8d
Revert "Delete NullableColorBindablePropertyHelper (I am afraid I did…
SymboLinker b928f4d
Use "foreach" instead of Xamarin.Forms.Internals.ForEach
SymboLinker afa9f55
First call SetButtonsTextColor and then SetClearButtonImageSource
SymboLinker e229992
Update CSharpMath.Forms.Example/CSharpMath.Forms.Example/Controls/Mat…
SymboLinker 86c9bbb
Merge pull request #6 from verybadcat/master
SymboLinker 3c76e83
Add unit tests MathButtonTextColorCanChangeMultipleTimes and MathInpu…
SymboLinker 486ac0f
Introduce interface IButtonDraw for bindablePropertyChanged
SymboLinker ae04c89
Shut CSharpMath.Ios.Tests
Happypig375 1426a9a
add lock for now
FoggyFinder edfed19
Create and use method SubStringCount() instead of Regex.Matches().Count
SymboLinker db93ac9
Customized placeholder colors: add unit test
SymboLinker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using CSharpMath.Editor; | ||
using Xamarin.Forms; | ||
using Xunit; | ||
namespace CSharpMath.Forms.Tests { | ||
public class ButtonTests { | ||
[Fact] | ||
public void ChangingButtonTextColorDoesNotChangeLatexPropertyValue() { | ||
var latexContent = @"1\leq 2"; | ||
var newColor = Color.Gray; | ||
|
||
var mathButton = new MathButton { Content = new MathView { LaTeX = latexContent } }; | ||
mathButton.TextColor = newColor; | ||
Assert.Equal(mathButton.TextColor, newColor); | ||
Assert.Equal(latexContent, mathButton.Content.LaTeX); | ||
|
||
var textButton = new TextButton { Content = new TextView { LaTeX = latexContent } }; | ||
textButton.TextColor = newColor; | ||
Assert.Equal(mathButton.TextColor, newColor); | ||
Assert.Equal(latexContent, textButton.Content.LaTeX); | ||
} | ||
[Theory] | ||
[ClassData(typeof(TheMathInputButtons))] | ||
public void AllMathInputButtonsHaveLatexContent(MathInputButton mathInputButton) { | ||
Assert.False(string.IsNullOrEmpty(mathInputButton.Content?.LaTeX)); | ||
} | ||
[Theory] | ||
[ClassData(typeof(TheMathInputButtons))] | ||
public void MathInputButtonsHaveBlackTextColorByDefault(MathInputButton mathInputButton) { | ||
// At the time of writing this test, vphatom = @"{\color{#00FFFFFF}{|}}" (Xamarin.Forms.Color.Transparent = "#00FFFFFF") is used as there is no \vphantom command yet. | ||
// As soon as \vphantom has been implemented, the call .Replace(LatexHelper.vphantom, "") can be removed. | ||
Assert.DoesNotContain(@"\color", mathInputButton.Content.NotNull().LaTeX.NotNull().Replace(LatexHelper.vphantom, "")); | ||
Assert.Equal(Color.Black, mathInputButton.TextColor); | ||
} | ||
[Theory] | ||
[ClassData(typeof(TheMathInputButtons))] | ||
public void MathInputButtonsHaveTransparentBackgroundByDefault(MathInputButton mathInputButton) { | ||
Assert.Equal(Color.Transparent, mathInputButton.BackgroundColor); | ||
} | ||
Happypig375 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public class TheMathInputButtons : TestHelpers.ComplexClassData<MathInputButton> { | ||
Happypig375 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public override IEnumerable<MathInputButton> theData => | ||
Enum.GetValues(typeof(MathKeyboardInput)).Cast<MathKeyboardInput>().Select(input => new MathInputButton { Input = input }); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<EmbeddedResource Include="..\CSharpMath.Rendering.Tests\ComicNeue_Bold.otf" Link="ComicNeue_Bold.otf" /> | ||
Happypig375 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<ProjectReference Include="..\CSharpMath.Forms\CSharpMath.Forms.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Collections.Generic; | ||
namespace CSharpMath.Forms.Tests.TestHelpers { | ||
public abstract class ComplexClassData<T> : IEnumerable<object[]> where T : class { | ||
Happypig375 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public abstract IEnumerable<T> theData { get; } | ||
IEnumerator<object[]> IEnumerable<object[]>.GetEnumerator() { | ||
foreach (var item in theData) | ||
yield return new object[] { item }; | ||
} | ||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => ((IEnumerable<object[]>)this).GetEnumerator(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace CSharpMath.Forms.Tests { | ||
public static class Extensions { | ||
public static T NotNull<T>(this T? obj) where T : class { | ||
if (obj == null) | ||
throw new Xunit.Sdk.NotNullException(); | ||
#nullable disable | ||
return obj; | ||
#nullable restore | ||
Happypig375 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xamarin.Forms; | ||
|
||
namespace CSharpMath.Forms { | ||
public static class LatexHelper { | ||
public static readonly string vphantom = SetColor("|", Color.Transparent); | ||
Happypig375 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public static string SetColor(string latex, Color color) => @"{\color{" + color.ToHex() + "}{" + latex + "}}"; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.