From 91b6bc4fe1c9633a8b34ff528c0b23fdf527086a Mon Sep 17 00:00:00 2001 From: Rafael Osipov Date: Wed, 29 Jan 2025 19:31:48 +0300 Subject: [PATCH 1/5] refactor: Minor refactoring to improve performance/memory consumption --- .../MAUI.FreakyControls/Converters/InverseBoolConverter.cs | 2 +- .../MAUI.FreakyControls/Extensions/CollectionExtensions.cs | 2 +- .../MAUI.FreakyControls/Extensions/StreamExtensions.cs | 2 +- .../MAUI.FreakyControls/Helpers/DownloadHelper.cs | 2 +- .../MAUI.FreakyControls/Helpers/SizeOrScale.cs | 6 +++--- .../Android/FreakySignatureCanvasViewHandler.android.cs | 2 +- .../MAUI.FreakyControls/Wrappers/StreamWrapper.cs | 5 +++-- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Converters/InverseBoolConverter.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Converters/InverseBoolConverter.cs index 704895af..da779069 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Converters/InverseBoolConverter.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Converters/InverseBoolConverter.cs @@ -6,7 +6,7 @@ public class InverseBoolConverter : BaseOneWayValueConverter { public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (!(value is bool boolValue)) + if (value is not bool boolValue) { throw new ArgumentException("Value must be a boolean", nameof(value)); } diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/CollectionExtensions.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/CollectionExtensions.cs index b8adef4f..fdb39b6c 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/CollectionExtensions.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/CollectionExtensions.cs @@ -6,7 +6,7 @@ public static class CollectionExtensions { public static ObservableCollection ToObservable(this IEnumerable col) { - return new ObservableCollection(col); + return [.. col]; } public static IEnumerable<(T item, int index)> WithIndex(this IEnumerable self) => self?.Select((item, index) => (item, index)) ?? new List<(T, int)>(); diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/StreamExtensions.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/StreamExtensions.cs index f6a81aff..61c4cd99 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/StreamExtensions.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Extensions/StreamExtensions.cs @@ -4,7 +4,7 @@ public static class StreamExtensions { public static MemoryStream GetMemoryStream(this Stream stream) { - MemoryStream memoryStream = new MemoryStream(); + MemoryStream memoryStream = new(); stream.CopyTo(memoryStream); memoryStream.Position = 0; return memoryStream; diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/DownloadHelper.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/DownloadHelper.cs index 88e13ce9..4779476d 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/DownloadHelper.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/DownloadHelper.cs @@ -20,7 +20,7 @@ private static async Task DownloadStreamAsync(Uri uri, CancellationToken // Do not remove this await otherwise the client will dispose before // the stream even starts - return await StreamWrapper.GetStreamAsync(uri, cancellationToken, client).ConfigureAwait(false); + return await StreamWrapper.GetStreamAsync(uri, client, cancellationToken).ConfigureAwait(false); } catch (Exception ex) { diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/SizeOrScale.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/SizeOrScale.cs index 5d834dd3..035b27c1 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/SizeOrScale.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Helpers/SizeOrScale.cs @@ -60,9 +60,9 @@ public SizeOrScale(float x, float y, SizeOrScaleType type, bool keepAspectRatio) public bool KeepAspectRatio { get; set; } - public bool IsValid => X > 0 && Y > 0; + public readonly bool IsValid => X > 0 && Y > 0; - public Size GetScale(float width, float height) + public readonly Size GetScale(float width, float height) { if (Type == SizeOrScaleType.Scale) { @@ -74,7 +74,7 @@ public Size GetScale(float width, float height) } } - public Size GetSize(float width, float height) + public readonly Size GetSize(float width, float height) { if (Type == SizeOrScaleType.Scale) { diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Platforms/Android/FreakySignatureCanvasViewHandler.android.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Platforms/Android/FreakySignatureCanvasViewHandler.android.cs index f7786d85..b662b34e 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Platforms/Android/FreakySignatureCanvasViewHandler.android.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Platforms/Android/FreakySignatureCanvasViewHandler.android.cs @@ -10,7 +10,7 @@ protected override Platforms.Android.SignaturePadCanvasView private void OnImageStreamRequested(object sender, ImageStreamRequestedEventArgs e) { - var ctrl = this.PlatformView; + var ctrl = PlatformView; if (ctrl is not null) { var format = e.ImageFormat; diff --git a/MAUI.FreakyControls/MAUI.FreakyControls/Wrappers/StreamWrapper.cs b/MAUI.FreakyControls/MAUI.FreakyControls/Wrappers/StreamWrapper.cs index 376bb061..2751c2a4 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls/Wrappers/StreamWrapper.cs +++ b/MAUI.FreakyControls/MAUI.FreakyControls/Wrappers/StreamWrapper.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.Threading; namespace Maui.FreakyControls.Wrappers { @@ -83,7 +84,7 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } - public static async Task GetStreamAsync(Uri uri, CancellationToken cancellationToken, HttpClient client) + public static async Task GetStreamAsync(Uri uri, HttpClient client, CancellationToken cancellationToken) { var response = await client.GetAsync(uri, cancellationToken).ConfigureAwait(false); if (!response.IsSuccessStatusCode) @@ -96,7 +97,7 @@ public static async Task GetStreamAsync(Uri uri, CancellationToken cance // the HttpResponseMessage needs to be disposed of after the calling code is done with the stream // otherwise the stream may get disposed before the caller can use it - return new StreamWrapper(await response.Content.ReadAsStreamAsync().ConfigureAwait(false), response); + return new StreamWrapper(await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false), response); } } } \ No newline at end of file From 5480e2e4885d498eead5785dbfad29a259cd5bcd Mon Sep 17 00:00:00 2001 From: Rafael Osipov Date: Wed, 29 Jan 2025 20:12:46 +0300 Subject: [PATCH 2/5] refactor: Improve readability --- MAUI.FreakyControls/MAUI.FreakyControls.sln | 12 ++--- MAUI.FreakyControls/Samples/AppShell.xaml.cs | 52 +++++++++---------- MAUI.FreakyControls/Samples/ImageUrls.cs | 30 +++++------ .../Samples/InputViews/InputViewModel.cs | 2 +- .../Samples/JumpList/JumpListViewModel.cs | 3 +- MAUI.FreakyControls/Samples/MainPage.xaml.cs | 16 +++--- MAUI.FreakyControls/Samples/MainViewModel.cs | 36 ++++++------- .../Samples/SignatureView/ImageDisplay.cs | 4 +- .../Samples/SwipeCardView/ImageUrls.cs | 30 +++++------ .../SwipeCardView/SwipeCardViewModel.cs | 32 ++++++------ 10 files changed, 106 insertions(+), 111 deletions(-) diff --git a/MAUI.FreakyControls/MAUI.FreakyControls.sln b/MAUI.FreakyControls/MAUI.FreakyControls.sln index 596d4c38..9f42cec4 100644 --- a/MAUI.FreakyControls/MAUI.FreakyControls.sln +++ b/MAUI.FreakyControls/MAUI.FreakyControls.sln @@ -1,7 +1,6 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 25.0.1703.2 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35723.152 d17.13 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples", "Samples\Samples.csproj", "{FA323AEE-85A9-4D5D-9726-03C7D1FD71A2}" EndProject @@ -15,16 +14,13 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution {FA323AEE-85A9-4D5D-9726-03C7D1FD71A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FA323AEE-85A9-4D5D-9726-03C7D1FD71A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA323AEE-85A9-4D5D-9726-03C7D1FD71A2}.Debug|Any CPU.Deploy.0 = Debug|Any CPU {FA323AEE-85A9-4D5D-9726-03C7D1FD71A2}.Release|Any CPU.ActiveCfg = Release|Any CPU {FA323AEE-85A9-4D5D-9726-03C7D1FD71A2}.Release|Any CPU.Build.0 = Release|Any CPU {864B4829-7286-4921-A185-DA67FE0D1155}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {864B4829-7286-4921-A185-DA67FE0D1155}.Debug|Any CPU.Build.0 = Debug|Any CPU {864B4829-7286-4921-A185-DA67FE0D1155}.Release|Any CPU.ActiveCfg = Release|Any CPU {864B4829-7286-4921-A185-DA67FE0D1155}.Release|Any CPU.Build.0 = Release|Any CPU - {C80669FA-43B5-4B68-9819-30BFD1915031}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C80669FA-43B5-4B68-9819-30BFD1915031}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C80669FA-43B5-4B68-9819-30BFD1915031}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C80669FA-43B5-4B68-9819-30BFD1915031}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -32,4 +28,4 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3A49EF6E-4CF5-41B1-8F23-FCD2AC812C50} EndGlobalSection -EndGlobal \ No newline at end of file +EndGlobal diff --git a/MAUI.FreakyControls/Samples/AppShell.xaml.cs b/MAUI.FreakyControls/Samples/AppShell.xaml.cs index b1fc5e0b..0a45e9b0 100644 --- a/MAUI.FreakyControls/Samples/AppShell.xaml.cs +++ b/MAUI.FreakyControls/Samples/AppShell.xaml.cs @@ -2,35 +2,35 @@ namespace Samples; public partial class AppShell : Shell { - internal const string buttons = "Buttons"; - internal const string checkboxes = "Checkboxes"; - internal const string imageViews = "ImageViews"; - internal const string inputViews = "InputViews"; - internal const string pickers = "Pickers"; - internal const string radioButtons = "RadioButtons"; - internal const string signaturePreview = "ImageDisplay"; - internal const string signatureView = "SignatureView"; - internal const string textInputLayout = "TextInputLayouts"; - internal const string jumpList = "JumpList"; - internal const string pinView = "PinView"; - internal const string switches = "Switch"; - internal const string zoomImage = "ZoomImage"; + internal const string Buttons = "Buttons"; + internal const string Checkboxes = "Checkboxes"; + internal const string ImageViews = "ImageViews"; + internal const string InputViews = "InputViews"; + internal const string Pickers = "Pickers"; + internal const string RadioButtons = "RadioButtons"; + internal const string SignaturePreview = "ImageDisplay"; + internal const string SignatureView = "SignatureView"; + internal const string TextInputLayout = "TextInputLayouts"; + internal const string JumpList = "JumpList"; + internal const string PinView = "PinView"; + internal const string Switches = "Switch"; + internal const string ZoomImage = "ZoomImage"; public AppShell() { InitializeComponent(); - Routing.RegisterRoute(inputViews, typeof(InputViews.InputViews)); - Routing.RegisterRoute(pickers, typeof(Pickers.PickersView)); - Routing.RegisterRoute(textInputLayout, typeof(TextInputLayout.TextInputLayoutView)); - Routing.RegisterRoute(imageViews, typeof(ImageViews.ImagesPage)); - Routing.RegisterRoute(signatureView, typeof(SignatureView.SignatureView)); - Routing.RegisterRoute(signaturePreview, typeof(SignatureView.ImageDisplay)); - Routing.RegisterRoute(checkboxes, typeof(Checkboxes.CheckboxesView)); - Routing.RegisterRoute(radioButtons, typeof(RadioButtons.RadioButtonsView)); - Routing.RegisterRoute(buttons, typeof(ButtonsView.ButtonsView)); - Routing.RegisterRoute(jumpList, typeof(JumpList.JumpListView)); - Routing.RegisterRoute(pinView, typeof(PinView.PinView)); - Routing.RegisterRoute(switches, typeof(Switch.SwitchsView)); - Routing.RegisterRoute(zoomImage, typeof(ZoomImage.ZoomImageView)); + Routing.RegisterRoute(InputViews, typeof(InputViews.InputViews)); + Routing.RegisterRoute(Pickers, typeof(Pickers.PickersView)); + Routing.RegisterRoute(TextInputLayout, typeof(TextInputLayout.TextInputLayoutView)); + Routing.RegisterRoute(ImageViews, typeof(ImageViews.ImagesPage)); + Routing.RegisterRoute(SignatureView, typeof(SignatureView.SignatureView)); + Routing.RegisterRoute(SignaturePreview, typeof(SignatureView.ImageDisplay)); + Routing.RegisterRoute(Checkboxes, typeof(Checkboxes.CheckboxesView)); + Routing.RegisterRoute(RadioButtons, typeof(RadioButtons.RadioButtonsView)); + Routing.RegisterRoute(Buttons, typeof(ButtonsView.ButtonsView)); + Routing.RegisterRoute(JumpList, typeof(JumpList.JumpListView)); + Routing.RegisterRoute(PinView, typeof(PinView.PinView)); + Routing.RegisterRoute(Switches, typeof(Switch.SwitchsView)); + Routing.RegisterRoute(ZoomImage, typeof(ZoomImage.ZoomImageView)); } } \ No newline at end of file diff --git a/MAUI.FreakyControls/Samples/ImageUrls.cs b/MAUI.FreakyControls/Samples/ImageUrls.cs index db920cd1..35ea93ae 100644 --- a/MAUI.FreakyControls/Samples/ImageUrls.cs +++ b/MAUI.FreakyControls/Samples/ImageUrls.cs @@ -2,20 +2,20 @@ namespace Samples; public static class ImageUrls { - public const string female1 = "https://static.displate.com/280x392/displate/2023-12-14/0e8bf99c32274f779851ee93b367ae8b_247fa401e8831ffd3eb34b159e2332f3.jpg"; - public const string female2 = "https://img.freepik.com/premium-vector/young-girl-anime-style-character-vector-illustration-design-manga-anime-girl_147933-100.jpg"; - public const string female3 = "https://i.pinimg.com/736x/f8/50/02/f8500297dfc066019cae88ebd15dabeb.jpg"; - public const string female4 = "https://rukminim2.flixcart.com/image/850/1000/kxkqavk0/poster/m/6/p/medium-anime-girls-original-characters-women-black-hair-long-original-imagayfvhs5gymjt.jpeg?q=90&crop=false"; - public const string female5 = "https://i.pinimg.com/originals/6c/65/87/6c6587847c664394540e8f2c7bde3ac3.jpg"; - public const string female6 = "https://w0.peakpx.com/wallpaper/368/441/HD-wallpaper-cute-anime-girl-anime-cat-girl-anime-girl-cartoon-cat-girl-cute-anime.jpg"; - public const string female7 = "https://i.pinimg.com/736x/db/f4/bc/dbf4bc03c4ce45f944a177c463b3854c.jpg"; - public const string female8 = "https://thumbs.dreamstime.com/z/pretty-anime-woman-white-background-generative-ai-art-created-ai-technology-image-pretty-anime-woman-white-background-275547588.jpg"; - public const string female9 = "https://e0.pxfuel.com/wallpapers/600/658/desktop-wallpaper-10-cute-girl-anime-anime-top-cool-female-anime.jpg"; - public const string female10 = "https://cdn.pixabay.com/photo/2023/02/07/10/49/ai-generated-7773820_640.jpg"; + public const string Female1 = "https://static.displate.com/280x392/displate/2023-12-14/0e8bf99c32274f779851ee93b367ae8b_247fa401e8831ffd3eb34b159e2332f3.jpg"; + public const string Female2 = "https://img.freepik.com/premium-vector/young-girl-anime-style-character-vector-illustration-design-manga-anime-girl_147933-100.jpg"; + public const string Female3 = "https://i.pinimg.com/736x/f8/50/02/f8500297dfc066019cae88ebd15dabeb.jpg"; + public const string Female4 = "https://rukminim2.flixcart.com/image/850/1000/kxkqavk0/poster/m/6/p/medium-anime-girls-original-characters-women-black-hair-long-original-imagayfvhs5gymjt.jpeg?q=90&crop=false"; + public const string Female5 = "https://i.pinimg.com/originals/6c/65/87/6c6587847c664394540e8f2c7bde3ac3.jpg"; + public const string Female6 = "https://w0.peakpx.com/wallpaper/368/441/HD-wallpaper-cute-anime-girl-anime-cat-girl-anime-girl-cartoon-cat-girl-cute-anime.jpg"; + public const string Female7 = "https://i.pinimg.com/736x/db/f4/bc/dbf4bc03c4ce45f944a177c463b3854c.jpg"; + public const string Female8 = "https://thumbs.dreamstime.com/z/pretty-anime-woman-white-background-generative-ai-art-created-ai-technology-image-pretty-anime-woman-white-background-275547588.jpg"; + public const string Female9 = "https://e0.pxfuel.com/wallpapers/600/658/desktop-wallpaper-10-cute-girl-anime-anime-top-cool-female-anime.jpg"; + public const string Female10 = "https://cdn.pixabay.com/photo/2023/02/07/10/49/ai-generated-7773820_640.jpg"; - public const string male1 = "https://i.pinimg.com/originals/97/28/55/972855ed6c7539a2695d64193f59e041.jpg"; - public const string male2 = "https://i.pinimg.com/236x/0f/4a/e5/0f4ae561a4a23b7322ef59519c20de12.jpg"; - public const string male3 = "https://wallpapers.com/images/hd/white-hair-jujutsu-kaisen-gojo-0kxukr18bqmg50sk.jpg"; - public const string male4 = "https://w0.peakpx.com/wallpaper/871/38/HD-wallpaper-ban-seven-deadly-sins-anime-ban-seven-deadly-sins.jpg"; - public const string male5 = "https://i.pinimg.com/originals/3d/08/28/3d08280917ce517431135de1da94c54e.jpg"; + public const string Male1 = "https://i.pinimg.com/originals/97/28/55/972855ed6c7539a2695d64193f59e041.jpg"; + public const string Male2 = "https://i.pinimg.com/236x/0f/4a/e5/0f4ae561a4a23b7322ef59519c20de12.jpg"; + public const string Male3 = "https://wallpapers.com/images/hd/white-hair-jujutsu-kaisen-gojo-0kxukr18bqmg50sk.jpg"; + public const string Male4 = "https://w0.peakpx.com/wallpaper/871/38/HD-wallpaper-ban-seven-deadly-sins-anime-ban-seven-deadly-sins.jpg"; + public const string Male5 = "https://i.pinimg.com/originals/3d/08/28/3d08280917ce517431135de1da94c54e.jpg"; } diff --git a/MAUI.FreakyControls/Samples/InputViews/InputViewModel.cs b/MAUI.FreakyControls/Samples/InputViews/InputViewModel.cs index f84227e6..95127010 100644 --- a/MAUI.FreakyControls/Samples/InputViews/InputViewModel.cs +++ b/MAUI.FreakyControls/Samples/InputViews/InputViewModel.cs @@ -36,7 +36,7 @@ public InputViewModel() { NamesCollection = Names.ToObservable(); - NamesModel = names.Select(x => new AutoCompleteModel { Name = x }).ToList(); + NamesModel = [.. names.Select(x => new AutoCompleteModel { Name = x })]; NamesCollectionModel = NamesModel.ToObservable(); EntryCompleteCommand = new Command(ExecuteEntryCompleteCommand); diff --git a/MAUI.FreakyControls/Samples/JumpList/JumpListViewModel.cs b/MAUI.FreakyControls/Samples/JumpList/JumpListViewModel.cs index fc568653..70b42a01 100644 --- a/MAUI.FreakyControls/Samples/JumpList/JumpListViewModel.cs +++ b/MAUI.FreakyControls/Samples/JumpList/JumpListViewModel.cs @@ -35,6 +35,7 @@ public JumpListViewModel() "Yasmine", "Yael", "Yara", "Yaretzi", "Yvonne", "Yvette", "Yvaine", "Yelena", "Yara", "Yasmine", "Zachary", "Zoe", "Zachariah", "Zara", "Zayden", "Zuri", "Zane", "Zelda", "Zeke", "Zena" }; - Names = names.OrderBy(x => x).ToList(); + + Names = [.. names.OrderBy(x => x)]; } } \ No newline at end of file diff --git a/MAUI.FreakyControls/Samples/MainPage.xaml.cs b/MAUI.FreakyControls/Samples/MainPage.xaml.cs index 6c5b6c46..7733c9bf 100644 --- a/MAUI.FreakyControls/Samples/MainPage.xaml.cs +++ b/MAUI.FreakyControls/Samples/MainPage.xaml.cs @@ -2,7 +2,7 @@ public partial class MainPage : ContentPage { - private MainViewModel vm; + private readonly MainViewModel vm; public MainPage() { @@ -10,22 +10,22 @@ public MainPage() InitializeComponent(); } - private async void FreakySvgImageView_Tapped(object sender, System.EventArgs e) + private async void FreakySvgImageView_Tapped(object sender, EventArgs e) { - await this.DisplayAlert("Yo", "Hi from the dotnet bot", "Ok"); + await DisplayAlert("Yo", "Hi from the dotnet bot", "Ok"); } - private async void OnButtonClicked(System.Object sender, System.EventArgs e) + private async void OnButtonClicked(object sender, EventArgs e) { - await this.DisplayAlert("Yo", "I am a freaky button", "Ok"); + await DisplayAlert("Yo", "I am a freaky button", "Ok"); } - private async void ListView_ItemTapped(System.Object sender, Microsoft.Maui.Controls.ItemTappedEventArgs e) + private async void ListView_ItemTapped(object sender, ItemTappedEventArgs e) { string route = e.Item.ToString(); - if (route == AppShell.jumpList) + if (route == AppShell.JumpList) { - var permission = await Samples.PermissionHelper.CheckAndRequestPermissionAsync(); + var permission = await PermissionHelper.CheckAndRequestPermissionAsync(); if (permission != PermissionStatus.Granted) { await DisplayAlert("Error", "Needs vibration permission for haptik feedback", "Ok"); diff --git a/MAUI.FreakyControls/Samples/MainViewModel.cs b/MAUI.FreakyControls/Samples/MainViewModel.cs index 211721eb..066bbfd2 100644 --- a/MAUI.FreakyControls/Samples/MainViewModel.cs +++ b/MAUI.FreakyControls/Samples/MainViewModel.cs @@ -11,8 +11,8 @@ public class MainViewModel : BaseViewModel public List Names => names; - protected List names = new List - { + protected List names = + [ "Ava", "Amelia", "Adam", "Aaron", "Abigail", "Addison", "Alexandra", "Alice", "Ashley", "Aiden", "Benjamin", "Bella", "Brandon", "Brooke", "Blake", "Brian", "Brooklyn", "Bailey", "Bradley", "Brianna", "Charlotte", "Caleb", "Chloe", "Carter", "Christopher", "Claire", "Cameron", "Cassidy", "Cooper", "Caroline", @@ -39,28 +39,28 @@ public class MainViewModel : BaseViewModel "Xander", "Ximena", "Xavier", "Xanthe", "Xena", "Xia", "Xylia", "Xyla", "Xerxes", "Xylona", "Yasmine", "Yael", "Yara", "Yaretzi", "Yvonne", "Yvette", "Yvaine", "Yelena", "Yara", "Yasmine", "Zachary", "Zoe", "Zachariah", "Zara", "Zayden", "Zuri", "Zane", "Zelda", "Zeke", "Zena" - }; + ]; public MainViewModel() { ImageWasTappedCommand = new AsyncRelayCommand(ImageTappedAsync, new AsyncRelayCommandOptions()); FreakyLongPressedCommand = new AsyncRelayCommand(LongPressedAsync); - Items = new ObservableCollection - { - AppShell.pickers, - AppShell.textInputLayout, - AppShell.inputViews, - AppShell.imageViews, - AppShell.signatureView, - AppShell.checkboxes, - AppShell.radioButtons, - AppShell.buttons, - AppShell.jumpList, - AppShell.pinView, - AppShell.switches, - AppShell.zoomImage - }; + Items = + [ + AppShell.Pickers, + AppShell.TextInputLayout, + AppShell.InputViews, + AppShell.ImageViews, + AppShell.SignatureView, + AppShell.Checkboxes, + AppShell.RadioButtons, + AppShell.Buttons, + AppShell.JumpList, + AppShell.PinView, + AppShell.Switches, + AppShell.ZoomImage + ]; } public ICommand FreakyLongPressedCommand { get; set; } diff --git a/MAUI.FreakyControls/Samples/SignatureView/ImageDisplay.cs b/MAUI.FreakyControls/Samples/SignatureView/ImageDisplay.cs index 85a7a1b7..2780af12 100644 --- a/MAUI.FreakyControls/Samples/SignatureView/ImageDisplay.cs +++ b/MAUI.FreakyControls/Samples/SignatureView/ImageDisplay.cs @@ -1,6 +1,4 @@ -using Maui.FreakyControls; - -namespace Samples.SignatureView; +namespace Samples.SignatureView; public class ImageDisplay : ContentPage { diff --git a/MAUI.FreakyControls/Samples/SwipeCardView/ImageUrls.cs b/MAUI.FreakyControls/Samples/SwipeCardView/ImageUrls.cs index 2cab1fc1..34b29047 100644 --- a/MAUI.FreakyControls/Samples/SwipeCardView/ImageUrls.cs +++ b/MAUI.FreakyControls/Samples/SwipeCardView/ImageUrls.cs @@ -2,20 +2,20 @@ namespace Samples.SwipeCardView; public static class ImageUrls { - public const string female1 = "https://static.displate.com/280x392/displate/2023-12-14/0e8bf99c32274f779851ee93b367ae8b_247fa401e8831ffd3eb34b159e2332f3.jpg"; - public const string female2 = "https://img.freepik.com/premium-vector/young-girl-anime-style-character-vector-illustration-design-manga-anime-girl_147933-100.jpg"; - public const string female3 = "https://i.pinimg.com/736x/f8/50/02/f8500297dfc066019cae88ebd15dabeb.jpg"; - public const string female4 = "https://rukminim2.flixcart.com/image/850/1000/kxkqavk0/poster/m/6/p/medium-anime-girls-original-characters-women-black-hair-long-original-imagayfvhs5gymjt.jpeg?q=90&crop=false"; - public const string female5 = "https://i.pinimg.com/originals/6c/65/87/6c6587847c664394540e8f2c7bde3ac3.jpg"; - public const string female6 = "https://w0.peakpx.com/wallpaper/368/441/HD-wallpaper-cute-anime-girl-anime-cat-girl-anime-girl-cartoon-cat-girl-cute-anime.jpg"; - public const string female7 = "https://i.pinimg.com/736x/db/f4/bc/dbf4bc03c4ce45f944a177c463b3854c.jpg"; - public const string female8 = "https://thumbs.dreamstime.com/z/pretty-anime-woman-white-background-generative-ai-art-created-ai-technology-image-pretty-anime-woman-white-background-275547588.jpg"; - public const string female9 = "https://e0.pxfuel.com/wallpapers/600/658/desktop-wallpaper-10-cute-girl-anime-anime-top-cool-female-anime.jpg"; - public const string female10 = "https://cdn.pixabay.com/photo/2023/02/07/10/49/ai-generated-7773820_640.jpg"; + public const string Female1 = "https://static.displate.com/280x392/displate/2023-12-14/0e8bf99c32274f779851ee93b367ae8b_247fa401e8831ffd3eb34b159e2332f3.jpg"; + public const string Female2 = "https://img.freepik.com/premium-vector/young-girl-anime-style-character-vector-illustration-design-manga-anime-girl_147933-100.jpg"; + public const string Female3 = "https://i.pinimg.com/736x/f8/50/02/f8500297dfc066019cae88ebd15dabeb.jpg"; + public const string Female4 = "https://rukminim2.flixcart.com/image/850/1000/kxkqavk0/poster/m/6/p/medium-anime-girls-original-characters-women-black-hair-long-original-imagayfvhs5gymjt.jpeg?q=90&crop=false"; + public const string Female5 = "https://i.pinimg.com/originals/6c/65/87/6c6587847c664394540e8f2c7bde3ac3.jpg"; + public const string Female6 = "https://w0.peakpx.com/wallpaper/368/441/HD-wallpaper-cute-anime-girl-anime-cat-girl-anime-girl-cartoon-cat-girl-cute-anime.jpg"; + public const string Female7 = "https://i.pinimg.com/736x/db/f4/bc/dbf4bc03c4ce45f944a177c463b3854c.jpg"; + public const string Female8 = "https://thumbs.dreamstime.com/z/pretty-anime-woman-white-background-generative-ai-art-created-ai-technology-image-pretty-anime-woman-white-background-275547588.jpg"; + public const string Female9 = "https://e0.pxfuel.com/wallpapers/600/658/desktop-wallpaper-10-cute-girl-anime-anime-top-cool-female-anime.jpg"; + public const string Female10 = "https://cdn.pixabay.com/photo/2023/02/07/10/49/ai-generated-7773820_640.jpg"; - public const string male1 = "https://i.pinimg.com/originals/97/28/55/972855ed6c7539a2695d64193f59e041.jpg"; - public const string male2 = "https://i.pinimg.com/236x/0f/4a/e5/0f4ae561a4a23b7322ef59519c20de12.jpg"; - public const string male3 = "https://wallpapers.com/images/hd/white-hair-jujutsu-kaisen-gojo-0kxukr18bqmg50sk.jpg"; - public const string male4 = "https://w0.peakpx.com/wallpaper/871/38/HD-wallpaper-ban-seven-deadly-sins-anime-ban-seven-deadly-sins.jpg"; - public const string male5 = "https://i.pinimg.com/originals/3d/08/28/3d08280917ce517431135de1da94c54e.jpg"; + public const string Male1 = "https://i.pinimg.com/originals/97/28/55/972855ed6c7539a2695d64193f59e041.jpg"; + public const string Male2 = "https://i.pinimg.com/236x/0f/4a/e5/0f4ae561a4a23b7322ef59519c20de12.jpg"; + public const string Male3 = "https://wallpapers.com/images/hd/white-hair-jujutsu-kaisen-gojo-0kxukr18bqmg50sk.jpg"; + public const string Male4 = "https://w0.peakpx.com/wallpaper/871/38/HD-wallpaper-ban-seven-deadly-sins-anime-ban-seven-deadly-sins.jpg"; + public const string Male5 = "https://i.pinimg.com/originals/3d/08/28/3d08280917ce517431135de1da94c54e.jpg"; } diff --git a/MAUI.FreakyControls/Samples/SwipeCardView/SwipeCardViewModel.cs b/MAUI.FreakyControls/Samples/SwipeCardView/SwipeCardViewModel.cs index 868b45b8..dd8f1900 100644 --- a/MAUI.FreakyControls/Samples/SwipeCardView/SwipeCardViewModel.cs +++ b/MAUI.FreakyControls/Samples/SwipeCardView/SwipeCardViewModel.cs @@ -24,21 +24,21 @@ public SwipeCardViewModel() private void InitializeProfiles() { - Profiles.Add(new Profile { ProfileId = 1, Name = "Laura", Age = 24, Gender = Gender.Female, Photo = ImageUrls.female1}); - Profiles.Add(new Profile { ProfileId = 2, Name = "Sophia", Age = 21, Gender = Gender.Female, Photo = ImageUrls.female2 }); - Profiles.Add(new Profile { ProfileId = 3, Name = "Anne", Age = 19, Gender = Gender.Female, Photo = ImageUrls.female3 }); - Profiles.Add(new Profile { ProfileId = 4, Name = "Yvonne ", Age = 27, Gender = Gender.Female, Photo = ImageUrls.female4}); - Profiles.Add(new Profile { ProfileId = 5, Name = "Abby", Age = 25, Gender = Gender.Female, Photo = ImageUrls.female5 }); - Profiles.Add(new Profile { ProfileId = 6, Name = "Andressa", Age = 28, Gender = Gender.Female, Photo = ImageUrls.female6 }); - Profiles.Add(new Profile { ProfileId = 7, Name = "June", Age = 29, Gender = Gender.Female, Photo = ImageUrls.female7 }); - Profiles.Add(new Profile { ProfileId = 8, Name = "Kim", Age = 22, Gender = Gender.Female, Photo = ImageUrls.female8 }); - Profiles.Add(new Profile { ProfileId = 9, Name = "Denesha", Age = 26, Gender = Gender.Female, Photo = ImageUrls.female9}); - Profiles.Add(new Profile { ProfileId = 10, Name = "Sasha", Age = 23, Gender = Gender.Female, Photo = ImageUrls.female10}); - - Profiles.Add(new Profile { ProfileId = 11, Name = "Austin", Age = 28, Gender = Gender.Male, Photo = ImageUrls.male1 }); - Profiles.Add(new Profile { ProfileId = 11, Name = "James", Age = 32, Gender = Gender.Male, Photo = ImageUrls.male2 }); - Profiles.Add(new Profile { ProfileId = 11, Name = "Chris", Age = 27, Gender = Gender.Male, Photo = ImageUrls.male3 }); - Profiles.Add(new Profile { ProfileId = 11, Name = "Alexander", Age = 30, Gender = Gender.Male, Photo = ImageUrls.male4 }); - Profiles.Add(new Profile { ProfileId = 11, Name = "Steve", Age = 31, Gender = Gender.Male, Photo = ImageUrls.male5 }); + Profiles.Add(new Profile { ProfileId = 1, Name = "Laura", Age = 24, Gender = Gender.Female, Photo = ImageUrls.Female1}); + Profiles.Add(new Profile { ProfileId = 2, Name = "Sophia", Age = 21, Gender = Gender.Female, Photo = ImageUrls.Female2 }); + Profiles.Add(new Profile { ProfileId = 3, Name = "Anne", Age = 19, Gender = Gender.Female, Photo = ImageUrls.Female3 }); + Profiles.Add(new Profile { ProfileId = 4, Name = "Yvonne ", Age = 27, Gender = Gender.Female, Photo = ImageUrls.Female4}); + Profiles.Add(new Profile { ProfileId = 5, Name = "Abby", Age = 25, Gender = Gender.Female, Photo = ImageUrls.Female5 }); + Profiles.Add(new Profile { ProfileId = 6, Name = "Andressa", Age = 28, Gender = Gender.Female, Photo = ImageUrls.Female6 }); + Profiles.Add(new Profile { ProfileId = 7, Name = "June", Age = 29, Gender = Gender.Female, Photo = ImageUrls.Female7 }); + Profiles.Add(new Profile { ProfileId = 8, Name = "Kim", Age = 22, Gender = Gender.Female, Photo = ImageUrls.Female8 }); + Profiles.Add(new Profile { ProfileId = 9, Name = "Denesha", Age = 26, Gender = Gender.Female, Photo = ImageUrls.Female9}); + Profiles.Add(new Profile { ProfileId = 10, Name = "Sasha", Age = 23, Gender = Gender.Female, Photo = ImageUrls.Female10}); + + Profiles.Add(new Profile { ProfileId = 11, Name = "Austin", Age = 28, Gender = Gender.Male, Photo = ImageUrls.Male1 }); + Profiles.Add(new Profile { ProfileId = 11, Name = "James", Age = 32, Gender = Gender.Male, Photo = ImageUrls.Male2 }); + Profiles.Add(new Profile { ProfileId = 11, Name = "Chris", Age = 27, Gender = Gender.Male, Photo = ImageUrls.Male3 }); + Profiles.Add(new Profile { ProfileId = 11, Name = "Alexander", Age = 30, Gender = Gender.Male, Photo = ImageUrls.Male4 }); + Profiles.Add(new Profile { ProfileId = 11, Name = "Steve", Age = 31, Gender = Gender.Male, Photo = ImageUrls.Male5 }); } } From 34cf130d9356db3fd79bbd0f40225e1bc306ae38 Mon Sep 17 00:00:00 2001 From: Rafael Osipov Date: Wed, 29 Jan 2025 20:33:49 +0300 Subject: [PATCH 3/5] chore: Fix compilation error --- MAUI.FreakyControls/Samples/ZoomImage/ZoomImageView.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAUI.FreakyControls/Samples/ZoomImage/ZoomImageView.xaml b/MAUI.FreakyControls/Samples/ZoomImage/ZoomImageView.xaml index fac46f36..a81bb0c7 100644 --- a/MAUI.FreakyControls/Samples/ZoomImage/ZoomImageView.xaml +++ b/MAUI.FreakyControls/Samples/ZoomImage/ZoomImageView.xaml @@ -7,7 +7,7 @@ Title="ZoomImageView"> - + From 6dc3b7809548e45a90018fd6a0393257988fbd17 Mon Sep 17 00:00:00 2001 From: Rafael Osipov Date: Wed, 29 Jan 2025 20:42:54 +0300 Subject: [PATCH 4/5] refactor: Update profile ids --- .../Samples/SwipeCardView/SwipeCardViewModel.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MAUI.FreakyControls/Samples/SwipeCardView/SwipeCardViewModel.cs b/MAUI.FreakyControls/Samples/SwipeCardView/SwipeCardViewModel.cs index dd8f1900..50d410f2 100644 --- a/MAUI.FreakyControls/Samples/SwipeCardView/SwipeCardViewModel.cs +++ b/MAUI.FreakyControls/Samples/SwipeCardView/SwipeCardViewModel.cs @@ -36,9 +36,9 @@ private void InitializeProfiles() Profiles.Add(new Profile { ProfileId = 10, Name = "Sasha", Age = 23, Gender = Gender.Female, Photo = ImageUrls.Female10}); Profiles.Add(new Profile { ProfileId = 11, Name = "Austin", Age = 28, Gender = Gender.Male, Photo = ImageUrls.Male1 }); - Profiles.Add(new Profile { ProfileId = 11, Name = "James", Age = 32, Gender = Gender.Male, Photo = ImageUrls.Male2 }); - Profiles.Add(new Profile { ProfileId = 11, Name = "Chris", Age = 27, Gender = Gender.Male, Photo = ImageUrls.Male3 }); - Profiles.Add(new Profile { ProfileId = 11, Name = "Alexander", Age = 30, Gender = Gender.Male, Photo = ImageUrls.Male4 }); - Profiles.Add(new Profile { ProfileId = 11, Name = "Steve", Age = 31, Gender = Gender.Male, Photo = ImageUrls.Male5 }); + Profiles.Add(new Profile { ProfileId = 12, Name = "James", Age = 32, Gender = Gender.Male, Photo = ImageUrls.Male2 }); + Profiles.Add(new Profile { ProfileId = 13, Name = "Chris", Age = 27, Gender = Gender.Male, Photo = ImageUrls.Male3 }); + Profiles.Add(new Profile { ProfileId = 14, Name = "Alexander", Age = 30, Gender = Gender.Male, Photo = ImageUrls.Male4 }); + Profiles.Add(new Profile { ProfileId = 15, Name = "Steve", Age = 31, Gender = Gender.Male, Photo = ImageUrls.Male5 }); } } From 1dd41fca6728e6a7e3c60bb2c4a95cccb58adbdb Mon Sep 17 00:00:00 2001 From: Rafael Osipov Date: Wed, 29 Jan 2025 21:18:37 +0300 Subject: [PATCH 5/5] refactor: Add x:DataType to xaml pages --- MAUI.FreakyControls/Samples/Checkboxes/CheckboxesView.xaml | 3 +++ MAUI.FreakyControls/Samples/ImageViews/ImagesPage.xaml | 5 +++-- MAUI.FreakyControls/Samples/Pickers/PickersView.xaml | 3 +++ MAUI.FreakyControls/Samples/Pickers/PickersView.xaml.cs | 2 +- MAUI.FreakyControls/Samples/PinView/PinView.xaml | 4 ++++ .../Samples/RadioButtons/RadioButtonsView.xaml | 3 +++ MAUI.FreakyControls/Samples/SignatureView/SignatureView.xaml | 1 + MAUI.FreakyControls/Samples/Switch/SwitchsView.xaml | 5 ++++- MAUI.FreakyControls/Samples/ZoomImage/ZoomImageView.xaml | 3 +++ MAUI.FreakyControls/Samples/ZoomImage/ZoomImageViewModel.cs | 1 - 10 files changed, 25 insertions(+), 5 deletions(-) diff --git a/MAUI.FreakyControls/Samples/Checkboxes/CheckboxesView.xaml b/MAUI.FreakyControls/Samples/Checkboxes/CheckboxesView.xaml index bbe26983..9059cdab 100644 --- a/MAUI.FreakyControls/Samples/Checkboxes/CheckboxesView.xaml +++ b/MAUI.FreakyControls/Samples/Checkboxes/CheckboxesView.xaml @@ -5,7 +5,10 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:constants="clr-namespace:Samples" xmlns:freakyControls="clr-namespace:Maui.FreakyControls;assembly=Maui.FreakyControls" + xmlns:vm="clr-namespace:Samples.Checkboxes" + x:DataType="vm:CheckboxesViewModel" Title="CheckboxesView"> +