Skip to content

Commit

Permalink
popup created and Register page started.
Browse files Browse the repository at this point in the history
  • Loading branch information
gonultasmf committed May 6, 2024
1 parent 6bff7ed commit 1099faf
Show file tree
Hide file tree
Showing 12 changed files with 495 additions and 45 deletions.
7 changes: 6 additions & 1 deletion MyFinance/AppShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ public AppShell(IServiceProvider serviceProvider)
new ShellContent()
.Title("")
.ContentTemplate(() => serviceProvider.GetService<LoginPage>())
.Route("LoginPage")
.Route("LoginPage"),

new ShellContent()
.Title("")
.ContentTemplate(() => serviceProvider.GetService<MainPage>())
.Route("MainPage")
);
}
}
70 changes: 70 additions & 0 deletions MyFinance/Controls/GeneralPopup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
namespace MyFinance.Controls;

public partial class GeneralPopup : DXPopup
{
public GeneralPopup(string title, string desc, string okBtnTxt = "OK", PopupType pType = PopupType.Info, bool allowScrim = false)
{
var color = pType == PopupType.Info ? SkyBlue : pType == PopupType.Warning ? DarkOrange : Red;

this
.AllowScrim(allowScrim)
.AnimationDuration(new TimeSpan(0, 0, 0, 1))
.VerticalAlignment(PopupVerticalAlignment.Center)
.HorizontalAlignment(PopupHorizontalAlignment.Center)
.BackgroundColor(color)
.Content(
new Grid()
.WidthRequest(250)
.HeightRequest(150)
.Padding(0)
.Children(
new Frame()
.CornerRadius(25)
.BackgroundColor(color)
.BorderColor(color)
.FillBothDirections()
.Padding(0)
.Content(
new Grid()
.RowDefinitions(e => e.Star(2).Star(7).Star(1))
.FillBothDirections()
.Margin(10)
.Padding(10)
.Children(
new Label()
.Text(title)
.FontAttributes(Bold)
.FontSize(18)
.TextColor(Black)
.Center()
.Row(0),

new Label()
.Text(desc)
.FontAttributes(Italic)
.LineBreakMode(WordWrap)
.FontSize(12)
.TextColor(Black)
.Center()
.Row(1),

new Button()
.Text(okBtnTxt)
.TextColor(Black)
.FontAttributes(Bold)
.FontSize(15)
.Row(2)
.HeightRequest(30)
.BackgroundColor(DeepSkyBlue)
.CenterHorizontal()
.Padding(0)
.OnClicked((sender, e) =>
{
IsOpen = false;
})
)
)
)
);
}
}
96 changes: 96 additions & 0 deletions MyFinance/Controls/OperationPopup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using DevExpress.CodeParser;

namespace MyFinance.Controls;

public partial class OperationPopup : DXPopup
{
public static bool RESULT = false;
public OperationPopup(string title, string desc, string okBtnTxt = "OK", string cancelBtnTxt = "Cancel", PopupType pType = PopupType.Info, bool allowScrim = false)
{
var color = pType == PopupType.Info ? SkyBlue : pType == PopupType.Warning ? DarkOrange : Red;

this
.AllowScrim(allowScrim)
.AnimationDuration(new TimeSpan(0, 0, 0, 1))
.VerticalAlignment(PopupVerticalAlignment.Center)
.HorizontalAlignment(PopupHorizontalAlignment.Center)
.BackgroundColor(color)
.Content(
new Grid()
.WidthRequest(250)
.HeightRequest(150)
.Padding(0)
.Children(
new Frame()
.CornerRadius(25)
.BackgroundColor(color)
.BorderColor(color)
.FillBothDirections()
.Padding(0)
.Content(
new Grid()
.RowDefinitions(e => e.Star(2).Star(7).Star(1))
.FillBothDirections()
.Margin(10)
.Padding(10)
.Children(
new Label()
.Text(title)
.FontAttributes(Bold)
.FontSize(18)
.TextColor(Black)
.Center()
.Row(0),

new Label()
.Text(desc)
.FontAttributes(Italic)
.LineBreakMode(WordWrap)
.FontSize(12)
.TextColor(Black)
.Center()
.Row(1),

new HorizontalStackLayout()
.ColumnSpan(2)
.Row(2)
.Spacing(10)
.CenterHorizontal()
.Children(
new Button()
.Text(cancelBtnTxt)
.FontAttributes(Bold)
.FontSize(15)
.WidthRequest(100)
.IsVisible(pType == PopupType.Warning)
.BackgroundColor(IndianRed)
.Padding(0)
.HeightRequest(27)
.OnClicked((sender, e) =>
{
RESULT = false;
IsOpen = false;
}),

new Button()
.Text(okBtnTxt)
.FontAttributes(Bold)
.FontSize(15)
.WidthRequest(100)
.HeightRequest(25)
.BackgroundColor(DeepSkyBlue)
.AlignEnd()
.Padding(0)
.HeightRequest(27)
.OnClicked((sender, e) =>
{
RESULT = true;
IsOpen = false;
})
)
)
)
)
);
}
}
8 changes: 8 additions & 0 deletions MyFinance/Enums/PopupType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace MyFinance.Enums;

public enum PopupType
{
Info,
Warning,
Error
}
2 changes: 2 additions & 0 deletions MyFinance/Imports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
global using MyFinance.Context;
global using MyFinance.Repository;
global using MyFinance.DTOs;
global using MyFinance.Controls;

global using Microsoft.EntityFrameworkCore;

Expand All @@ -33,6 +34,7 @@
global using static Microsoft.Maui.Controls.LayoutAlignment;
global using static Microsoft.Maui.Graphics.Colors;
global using static Microsoft.Maui.TextDecorations;
global using static Microsoft.Maui.LineBreakMode;

global using MC = Microsoft.Maui.Controls;
global using DC = DevExpress.Maui.Controls;
4 changes: 2 additions & 2 deletions MyFinance/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace MyFinance;


[MauiMarkup(typeof(StatusBarBehavior), typeof(ShellContent), typeof(TextEdit), typeof(TextEditBase), typeof(EditBase))]
[MauiMarkup(typeof(PasswordEdit), typeof(CheckEdit), typeof(DXPopup))]
[MauiMarkup(typeof(StatusBarBehavior), typeof(TextEdit), typeof(TextEditBase), typeof(EditBase), typeof(ComboBoxEdit))]
[MauiMarkup(typeof(PasswordEdit), typeof(CheckEdit), typeof(DXPopup), typeof(ComboBoxEditBase), typeof(ItemsEditBase))]
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
Expand Down
2 changes: 1 addition & 1 deletion MyFinance/MyFinance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="DevExpress.Maui.Controls" Version="24.1.1-alpha-24085" />
<PackageReference Include="DevExpress.Maui.Editors" Version="24.1.1-alpha-24085" />
<PackageReference Include="FmgLib.MauiMarkup" Version="8.*" />
<PackageReference Include="FmgLib.MauiMarkup" Version="8.2.3-prev1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.21" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.21" />
Expand Down
45 changes: 42 additions & 3 deletions MyFinance/Resources/Styles/AppStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,49 @@ public class AppStyles
{
public static ResourceDictionary Default => new ResourceDictionary {

// "TextEdit"

new Style<TextEdit>(e => e
.LabelColor(DeepSkyBlue)
.BorderColor(DeepSkyBlue)
.FocusedBorderColor(DeepSkyBlue)
.FocusedLabelColor(DeepSkyBlue)
.CursorColor(DeepSkyBlue)
.LabelFontSize(14)),

// "PasswordEdit"

new Style<PasswordEdit>(e => e
.LabelColor(DeepSkyBlue)
.BorderColor(DeepSkyBlue)
.FocusedBorderColor(DeepSkyBlue)
.FocusedLabelColor(DeepSkyBlue)
.CursorColor(DeepSkyBlue)
.LabelFontSize(14)),

// "CheckEdit"

new Style<CheckEdit>(e => e
.LabelFontSize(12)
.CheckBoxColor(DeepSkyBlue)
.CheckedCheckBoxColor(DeepSkyBlue)
.LabelVerticalAlignment(TextAlignment.Center)),

// "ComboBoxEdit"

new Style<ComboBoxEdit>(e => e
.LabelColor(DeepSkyBlue)
.BorderColor(DeepSkyBlue)
.FocusedBorderColor(DeepSkyBlue)
.FocusedLabelColor(DeepSkyBlue)
.CursorColor(DeepSkyBlue)
.LabelFontSize(14)),

// "ActivityIndicator"

new Style<ActivityIndicator>(e => e
.Color(e => e.OnLight(AppColors.Primary).OnDark(Colors.White))),
.Color(DeepSkyBlue)
/*.Color(e => e.OnLight(AppColors.Primary).OnDark(Colors.White))*/),

// "IndicatorView"

Expand All @@ -34,8 +73,8 @@ public class AppStyles
// "Button"

new Style<Button>(e => e
.TextColor(e => e.OnLight(Colors.White).OnDark(AppColors.Primary))
.BackgroundColor(e => e.OnLight(AppColors.Primary).OnDark(Colors.White))
.TextColor(Black)
.BackgroundColor(DeepSkyBlue)
.FontFamily("OpenSansRegular")
.FontSize(14)
.CornerRadius(8)
Expand Down
49 changes: 49 additions & 0 deletions MyFinance/ViewModels/RegisterPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System.Windows.Input;

namespace MyFinance.ViewModels;

public partial class RegisterPageViewModel(IUserRepo repo) : BaseViewModel
{
[ObservableProperty]
private User userModel = new()
{
Email = string.Empty,
FirstName = string.Empty,
LastName = string.Empty,
Password = string.Empty
};

[ObservableProperty]
private bool isPopupShow = false;

[ObservableProperty]
private bool isUserAdded = false;

public ICommand RegisterCommand => new Command(async () =>
{
if (UserModel == default!)
return;
UserModel.IsActive = true;
var result = await repo.InsertAsync(UserModel);
if (!result)
{
IsUserAdded = false;
IsPopupShow = true;
}
else
{
IsUserAdded = true;
IsPopupShow = true;
await AppShell.Current.GoToAsync($"//{nameof(LoginPage)}");
}
});

public ICommand GoToLoginCommand => new Command(async () =>
{
await AppShell.Current.GoToAsync($"//{nameof(LoginPage)}");
});


}
Loading

0 comments on commit 1099faf

Please sign in to comment.