Skip to content

Commit

Permalink
Merge pull request #4 from DevEddy/develop
Browse files Browse the repository at this point in the history
Develop into main
  • Loading branch information
DevEddy authored Mar 30, 2023
2 parents 384d7b7 + f9e490a commit bf638ac
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 17 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Resolved.It.Maui.App/Models/Country.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static Country Germany
public static Country French
=> Create(new Guid("2B08F8F1-3E3C-4B14-9C41-CB82C90BD7F5"), "Frankreich", "FR");
public static Country Austria
=> Create(new Guid("C5EA5E69-8E83-4E38-B946-50D1A2493A76"), "Österreich", "AT");
=> Create(new Guid("C5EA5E69-8E83-4E38-B946-50D1A2493A76"), "Oesterreich", "AT");

public static List<Country> GetCountryList()
{
Expand Down
8 changes: 0 additions & 8 deletions src/Resolved.It.Maui.App/Resolved.It.Maui.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,4 @@
<Folder Include="Models\" />
<Folder Include="Validations\" />
</ItemGroup>
<ItemGroup>
<MauiXaml Remove="Resources\Styles\Colors %28copy%29.xaml" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\Styles\FontIcons.xaml" Condition=" '$(EnableDefaultXamlItems)' == 'true' ">
<SubType>Designer</SubType>
</BundleResource>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Resolved.It.Maui.App/Resources/Styles/Styles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
<Setter Property="PlaceholderFocusedColor"
Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource Gray200}}" />
<Setter Property="PlaceholderBackgroundColor"
Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Black}}" />
Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Black}}" />
</Style>

</ResourceDictionary>
1 change: 1 addition & 0 deletions src/Resolved.It.Maui.App/ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class MainPageViewModel : BasePageViewModel

public ValidatableValue<string> Note { get; } = new();
public ValidatableValue<Country> SelectedCountry { get; } = new();
public ValidatableValue<string> Name { get; } = new();

public MainPageViewModel(INavigationService navigationService)
: base(navigationService)
Expand Down
4 changes: 2 additions & 2 deletions src/Resolved.It.Maui.App/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace Resolved.It.Maui.App.Views;

public partial class MainPage
{
public MainPage(MainPageViewModel nextPageViewModel)
public MainPage(MainPageViewModel mainPageViewModel)
{
BindingContext = nextPageViewModel;
BindingContext = mainPageViewModel;
InitializeComponent();
}
}
9 changes: 6 additions & 3 deletions src/Resolved.It.Maui.App/Views/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
namespace Resolved.It.Maui.App.Views;
using Resolved.It.Maui.App.ViewModels;

public partial class SettingsPage : ContentPage
namespace Resolved.It.Maui.App.Views;

public partial class SettingsPage
{
public SettingsPage()
public SettingsPage(SettingsPageViewModel settingsPageViewModel)
{
BindingContext = settingsPageViewModel;
InitializeComponent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@ private static void AddEvents(IElementHandler? handler)

private static void RemoveEvents(IElementHandler? handler)
{
}

private static void FillWidth(IElementHandler? handler)
{
}

private static void OpenDropdown(IElementHandler? handler)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@ private static void AddEvents(IElementHandler? handler)
private static void RemoveEvents(IElementHandler? handler)
{
}

private static void FillWidth(IElementHandler? handler)
{
}

private static void OpenDropdown(IElementHandler? handler)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,17 @@ private void SetupView()

_entryFrame.Content = _entryFrameContent;

var placeholderTapGesture = new TapGestureRecognizer();
placeholderTapGesture.Tapped += PlaceholderTapGestureOnTapped;
_placeholderLabel.GestureRecognizers.Add(placeholderTapGesture);

_placeholderLabel.SetBinding(Label.TextProperty, new Binding(nameof(Placeholder), source: this));

Children.Add(_entryFrame);
Children.Add(_placeholderLabel);
Children.Add(_errorLabel);
}

private static void ValidatableObjectChanged(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is not EnhancedEntry enhancedEntry)
Expand Down Expand Up @@ -425,12 +429,20 @@ private static void NewViewOnHandlerChanged(object? sender, EventArgs e)
// https://learn.microsoft.com/en-us/dotnet/maui/user-interface/handlers/customize?view=net-maui-7.0#conditional-compilation
AddEvents(view.Handler);
RemoveBorder(view.Handler);
FillWidth(view.Handler);
}

private void PlaceholderTapGestureOnTapped(object? sender, TappedEventArgs e)
{
_mainEntryControl?.Focus();
OpenDropdown(_mainEntryControl?.Handler);
UpdateControlsState(true);
}

private void UpdateControlsState(bool isFocused)
{
var hasValue = !string.IsNullOrWhiteSpace(ValidatableObject?.StringValue);

if (HasError)
{
_placeholderLabel.TextColor = PlaceholderErrorColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using HorizontalAlignment = Microsoft.UI.Xaml.HorizontalAlignment;

// ReSharper disable once CheckNamespace
namespace Resolved.It.Maui.Controls;
Expand Down Expand Up @@ -54,4 +55,20 @@ private static void TextBox_GettingFocus(UIElement sender, GettingFocusEventArgs
textBox.Resources["TextControlBorderThemeThicknessFocused"] = textBox.BorderThickness;
textBox.Resources["TextControlBorderThemeThickness"] = textBox.BorderThickness;
}

private static void FillWidth(IElementHandler? handler)
{
if (handler?.PlatformView is not Microsoft.UI.Xaml.Controls.ComboBox comboBox)
return;

comboBox.HorizontalAlignment = HorizontalAlignment.Stretch;
}

private static void OpenDropdown(IElementHandler? handler)
{
if (handler?.PlatformView is not Microsoft.UI.Xaml.Controls.ComboBox comboBox)
return;

comboBox.IsDropDownOpen = true;
}
}

0 comments on commit bf638ac

Please sign in to comment.