Skip to content

Commit

Permalink
Namespace change (#5)
Browse files Browse the repository at this point in the history
* update

* Update

* update
  • Loading branch information
IeuanWalker authored Apr 6, 2023
1 parent 78213ea commit f77ae34
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 68 deletions.
2 changes: 1 addition & 1 deletion Demo/App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Scr\StateButton.csproj" />
<ProjectReference Include="..\Scr\IeuanWalker.Maui.StateButton.csproj" />
</ItemGroup>


Expand Down
2 changes: 1 addition & 1 deletion Demo/ButtonNotInScrollViewPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ContentPage x:Class="App.ButtonNotInScrollViewPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:stateButton="clr-namespace:StateButton;assembly=StateButton"
xmlns:stateButton="clr-namespace:IeuanWalker.Maui.StateButton;assembly=IeuanWalker.Maui.StateButton"
BackgroundColor="White">
<ContentPage.Content>
<StackLayout Padding="20">
Expand Down
2 changes: 1 addition & 1 deletion Demo/ExamplePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ContentPage x:Class="App.ExamplePage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:stateButton="clr-namespace:StateButton;assembly=StateButton"
xmlns:stateButton="clr-namespace:IeuanWalker.Maui.StateButton;assembly=IeuanWalker.Maui.StateButton"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
Title="Examples"
BackgroundColor="White">
Expand Down
2 changes: 1 addition & 1 deletion Demo/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:app="clr-namespace:App.ViewModels;assembly=App"
xmlns:stateButton="clr-namespace:StateButton;assembly=StateButton"
xmlns:stateButton="clr-namespace:IeuanWalker.Maui.StateButton;assembly=IeuanWalker.Maui.StateButton"
BackgroundColor="White">
<ContentPage.BindingContext>
<app:TestViewModel />
Expand Down
2 changes: 1 addition & 1 deletion Demo/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using CommunityToolkit.Maui;
using StateButton;
using IeuanWalker.Maui.StateButton;

namespace App;

Expand Down
2 changes: 1 addition & 1 deletion Maui.StateButton.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Settings.XamlStyler = Settings.XamlStyler
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StateButton", "Scr\StateButton.csproj", "{613A4A03-673B-4ABC-9AFE-082A98281EE6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IeuanWalker.Maui.StateButton", "Scr\IeuanWalker.Maui.StateButton.csproj", "{613A4A03-673B-4ABC-9AFE-082A98281EE6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "App", "Demo\App.csproj", "{A3EA010F-13EE-4351-AC59-4F86336DB5F4}"
EndProject
Expand Down
6 changes: 3 additions & 3 deletions Scr/AppBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using StateButton.Handler;
using IeuanWalker.Maui.StateButton.Handler;

namespace StateButton;
namespace IeuanWalker.Maui.StateButton;

/// <summary>
/// This class contains CustomSwitch <see cref="MauiAppBuilder"/> extensions.
/// </summary>
public static class AppBuilderExtensions
{
/// <summary>
/// Initializes the Switch control
/// Initializes the StateButton control
/// </summary>
/// <param name="builder"><see cref="MauiAppBuilder"/> generated by <see cref="MauiApp"/>.</param>
/// <returns><see cref="MauiAppBuilder"/> initialized for <see cref="StateButton"/>.</returns>
Expand Down
2 changes: 1 addition & 1 deletion Scr/Enums/ButtonState.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace StateButton.Enums;
namespace IeuanWalker.Maui.StateButton.Enums;

public enum ButtonState
{
Expand Down
2 changes: 1 addition & 1 deletion Scr/Handler/IStateButtonHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Maui.Handlers;

namespace StateButton.Handler;
namespace IeuanWalker.Maui.StateButton.Handler;
public interface IStateButtonHandler : IBorderHandler
{
}
6 changes: 3 additions & 3 deletions Scr/Handler/StateButtonHandler.Android.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.Maui.Platform;
using IeuanWalker.Maui.StateButton.Platform;

namespace StateButton.Handler;
namespace IeuanWalker.Maui.StateButton.Handler;
public partial class StateButtonHandler
{
protected override ContentViewGroup CreatePlatformView()
protected override CustomContentViewGroup CreatePlatformView()
{
base.CreatePlatformView();

Expand Down
5 changes: 3 additions & 2 deletions Scr/Handler/StateButtonHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Maui.Handlers;
using IeuanWalker.Maui.StateButton.Handler;
using Microsoft.Maui.Handlers;

namespace StateButton.Handler;
namespace IeuanWalker.Maui.StateButton.Handler;

public partial class StateButtonHandler : BorderHandler, IStateButtonHandler
{
Expand Down
6 changes: 4 additions & 2 deletions Scr/Handler/StateButtonHandler.iOS.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
namespace StateButton.Handler;
using IeuanWalker.Maui.StateButton.Platform;

namespace IeuanWalker.Maui.StateButton.Handler;
public partial class StateButtonHandler
{
protected override Microsoft.Maui.Platform.ContentView CreatePlatformView()
protected override CustomContentView CreatePlatformView()
{
base.CreatePlatformView();

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Scr/Platform/CustomContentView.iOS.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Foundation;
using UIKit;

namespace StateButton.Handler;
namespace IeuanWalker.Maui.StateButton.Platform;

public class CustomContentView : Microsoft.Maui.Platform.ContentView
{
Expand Down
94 changes: 48 additions & 46 deletions Scr/Platform/CustomContentViewGroup.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
using Android.Runtime;
using Android.Views;
using Android.Views.Accessibility;
using Java.Lang;
using Microsoft.Maui.Platform;
using String = Java.Lang.String;

namespace StateButton.Handler;
namespace IeuanWalker.Maui.StateButton.Platform;
public class CustomContentViewGroup : ContentViewGroup
{
Rect _rect;
Expand All @@ -13,51 +15,63 @@ public CustomContentViewGroup(Context context, IBorderView virtualView) : base(c
{
_stateButton = (StateButton)virtualView;

//! important - this is what makes the switch accessible via keyboard navigation
Focusable = true;
Clickable = true;
}

public override bool OnTouchEvent(MotionEvent? e)
{
if(RootView is null)
Touch += (sender, te) =>
{
return base.OnTouchEvent(e);
}
if (sender is not Android.Views.View view)
{
return;
}
switch (e?.Action)
{
case MotionEventActions.Down:
_rect = new Rect(RootView.Left, RootView.Top, RootView.Right, RootView.Bottom);
_stateButton.InvokePressed();
break;
switch (te?.Event?.Action)
{
case MotionEventActions.Down:
_rect = new Rect(view.Left, view.Top, view.Right, view.Bottom);
case MotionEventActions.Up:
if (_rect.Contains(RootView.Left + (int)e.GetX(), RootView.Top + (int)e.GetY()))
{
_stateButton.InvokeReleased();
_stateButton.InvokeClicked();
}
else
{
_stateButton.InvokePressed();
break;
case MotionEventActions.Up:
if (_rect.Contains(view.Left + (int)te.Event.GetX(), view.Top + (int)te.Event.GetY()))
{
_stateButton.InvokeReleased();
_stateButton.InvokeClicked();
}
else
{
_stateButton.InvokeReleased();
}
break;
case MotionEventActions.Cancel:
_stateButton.InvokeReleased();
}
break;
case MotionEventActions.Cancel:
_stateButton.InvokeReleased();
break;
break;
case MotionEventActions.Move:
if (!_rect.Contains(view.Left + (int)te.Event.GetX(), view.Top + (int)te.Event.GetY()))
{
_stateButton.InvokeReleased();
}
case MotionEventActions.Move:
if (!_rect.Contains(RootView.Left + (int)e.GetX(), RootView.Top + (int)e.GetY()))
{
_stateButton.InvokeReleased();
}
break;
}
};
}

break;
public override ICharSequence? AccessibilityClassNameFormatted => new String("android.widget.Button");

public override void OnInitializeAccessibilityNodeInfo(AccessibilityNodeInfo? info)
{
if (info is not null)
{
info.Focusable = true;
info.Clickable = true;
}

return base.OnTouchEvent(e);
base.OnInitializeAccessibilityNodeInfo(info);
}

public override bool OnKeyUp([GeneratedEnum] Keycode keyCode, KeyEvent? e)
Expand All @@ -70,16 +84,4 @@ public override bool OnKeyUp([GeneratedEnum] Keycode keyCode, KeyEvent? e)

return base.OnKeyUp(keyCode, e);
}

public override void OnInitializeAccessibilityNodeInfo(AccessibilityNodeInfo? info)
{
if (info is not null)
{
info.Focusable = true;
info.Clickable = true;
info.ClassName = "android.widget.Button";
}

base.OnInitializeAccessibilityNodeInfo(info);
}
}
2 changes: 1 addition & 1 deletion Scr/StateButton.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Border x:Class="StateButton.StateButton"
<Border x:Class="IeuanWalker.Maui.StateButton.StateButton"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
BackgroundColor="Transparent"
Expand Down
4 changes: 2 additions & 2 deletions Scr/StateButton.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Windows.Input;
using StateButton.Enums;
using IeuanWalker.Maui.StateButton.Enums;

namespace StateButton;
namespace IeuanWalker.Maui.StateButton;

public partial class StateButton : Border
{
Expand Down

0 comments on commit f77ae34

Please sign in to comment.