Skip to content

Commit 1099faf

Browse files
committed
popup created and Register page started.
1 parent 6bff7ed commit 1099faf

12 files changed

+495
-45
lines changed

MyFinance/AppShell.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ public AppShell(IServiceProvider serviceProvider)
1515
new ShellContent()
1616
.Title("")
1717
.ContentTemplate(() => serviceProvider.GetService<LoginPage>())
18-
.Route("LoginPage")
18+
.Route("LoginPage"),
19+
20+
new ShellContent()
21+
.Title("")
22+
.ContentTemplate(() => serviceProvider.GetService<MainPage>())
23+
.Route("MainPage")
1924
);
2025
}
2126
}

MyFinance/Controls/GeneralPopup.cs

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
namespace MyFinance.Controls;
2+
3+
public partial class GeneralPopup : DXPopup
4+
{
5+
public GeneralPopup(string title, string desc, string okBtnTxt = "OK", PopupType pType = PopupType.Info, bool allowScrim = false)
6+
{
7+
var color = pType == PopupType.Info ? SkyBlue : pType == PopupType.Warning ? DarkOrange : Red;
8+
9+
this
10+
.AllowScrim(allowScrim)
11+
.AnimationDuration(new TimeSpan(0, 0, 0, 1))
12+
.VerticalAlignment(PopupVerticalAlignment.Center)
13+
.HorizontalAlignment(PopupHorizontalAlignment.Center)
14+
.BackgroundColor(color)
15+
.Content(
16+
new Grid()
17+
.WidthRequest(250)
18+
.HeightRequest(150)
19+
.Padding(0)
20+
.Children(
21+
new Frame()
22+
.CornerRadius(25)
23+
.BackgroundColor(color)
24+
.BorderColor(color)
25+
.FillBothDirections()
26+
.Padding(0)
27+
.Content(
28+
new Grid()
29+
.RowDefinitions(e => e.Star(2).Star(7).Star(1))
30+
.FillBothDirections()
31+
.Margin(10)
32+
.Padding(10)
33+
.Children(
34+
new Label()
35+
.Text(title)
36+
.FontAttributes(Bold)
37+
.FontSize(18)
38+
.TextColor(Black)
39+
.Center()
40+
.Row(0),
41+
42+
new Label()
43+
.Text(desc)
44+
.FontAttributes(Italic)
45+
.LineBreakMode(WordWrap)
46+
.FontSize(12)
47+
.TextColor(Black)
48+
.Center()
49+
.Row(1),
50+
51+
new Button()
52+
.Text(okBtnTxt)
53+
.TextColor(Black)
54+
.FontAttributes(Bold)
55+
.FontSize(15)
56+
.Row(2)
57+
.HeightRequest(30)
58+
.BackgroundColor(DeepSkyBlue)
59+
.CenterHorizontal()
60+
.Padding(0)
61+
.OnClicked((sender, e) =>
62+
{
63+
IsOpen = false;
64+
})
65+
)
66+
)
67+
)
68+
);
69+
}
70+
}

MyFinance/Controls/OperationPopup.cs

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
using DevExpress.CodeParser;
2+
3+
namespace MyFinance.Controls;
4+
5+
public partial class OperationPopup : DXPopup
6+
{
7+
public static bool RESULT = false;
8+
public OperationPopup(string title, string desc, string okBtnTxt = "OK", string cancelBtnTxt = "Cancel", PopupType pType = PopupType.Info, bool allowScrim = false)
9+
{
10+
var color = pType == PopupType.Info ? SkyBlue : pType == PopupType.Warning ? DarkOrange : Red;
11+
12+
this
13+
.AllowScrim(allowScrim)
14+
.AnimationDuration(new TimeSpan(0, 0, 0, 1))
15+
.VerticalAlignment(PopupVerticalAlignment.Center)
16+
.HorizontalAlignment(PopupHorizontalAlignment.Center)
17+
.BackgroundColor(color)
18+
.Content(
19+
new Grid()
20+
.WidthRequest(250)
21+
.HeightRequest(150)
22+
.Padding(0)
23+
.Children(
24+
new Frame()
25+
.CornerRadius(25)
26+
.BackgroundColor(color)
27+
.BorderColor(color)
28+
.FillBothDirections()
29+
.Padding(0)
30+
.Content(
31+
new Grid()
32+
.RowDefinitions(e => e.Star(2).Star(7).Star(1))
33+
.FillBothDirections()
34+
.Margin(10)
35+
.Padding(10)
36+
.Children(
37+
new Label()
38+
.Text(title)
39+
.FontAttributes(Bold)
40+
.FontSize(18)
41+
.TextColor(Black)
42+
.Center()
43+
.Row(0),
44+
45+
new Label()
46+
.Text(desc)
47+
.FontAttributes(Italic)
48+
.LineBreakMode(WordWrap)
49+
.FontSize(12)
50+
.TextColor(Black)
51+
.Center()
52+
.Row(1),
53+
54+
new HorizontalStackLayout()
55+
.ColumnSpan(2)
56+
.Row(2)
57+
.Spacing(10)
58+
.CenterHorizontal()
59+
.Children(
60+
new Button()
61+
.Text(cancelBtnTxt)
62+
.FontAttributes(Bold)
63+
.FontSize(15)
64+
.WidthRequest(100)
65+
.IsVisible(pType == PopupType.Warning)
66+
.BackgroundColor(IndianRed)
67+
.Padding(0)
68+
.HeightRequest(27)
69+
.OnClicked((sender, e) =>
70+
{
71+
RESULT = false;
72+
IsOpen = false;
73+
}),
74+
75+
new Button()
76+
.Text(okBtnTxt)
77+
.FontAttributes(Bold)
78+
.FontSize(15)
79+
.WidthRequest(100)
80+
.HeightRequest(25)
81+
.BackgroundColor(DeepSkyBlue)
82+
.AlignEnd()
83+
.Padding(0)
84+
.HeightRequest(27)
85+
.OnClicked((sender, e) =>
86+
{
87+
RESULT = true;
88+
IsOpen = false;
89+
})
90+
)
91+
)
92+
)
93+
)
94+
);
95+
}
96+
}

MyFinance/Enums/PopupType.cs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace MyFinance.Enums;
2+
3+
public enum PopupType
4+
{
5+
Info,
6+
Warning,
7+
Error
8+
}

MyFinance/Imports.cs

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
global using MyFinance.Context;
2121
global using MyFinance.Repository;
2222
global using MyFinance.DTOs;
23+
global using MyFinance.Controls;
2324

2425
global using Microsoft.EntityFrameworkCore;
2526

@@ -33,6 +34,7 @@
3334
global using static Microsoft.Maui.Controls.LayoutAlignment;
3435
global using static Microsoft.Maui.Graphics.Colors;
3536
global using static Microsoft.Maui.TextDecorations;
37+
global using static Microsoft.Maui.LineBreakMode;
3638

3739
global using MC = Microsoft.Maui.Controls;
3840
global using DC = DevExpress.Maui.Controls;

MyFinance/MauiProgram.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace MyFinance;
44

55

6-
[MauiMarkup(typeof(StatusBarBehavior), typeof(ShellContent), typeof(TextEdit), typeof(TextEditBase), typeof(EditBase))]
7-
[MauiMarkup(typeof(PasswordEdit), typeof(CheckEdit), typeof(DXPopup))]
6+
[MauiMarkup(typeof(StatusBarBehavior), typeof(TextEdit), typeof(TextEditBase), typeof(EditBase), typeof(ComboBoxEdit))]
7+
[MauiMarkup(typeof(PasswordEdit), typeof(CheckEdit), typeof(DXPopup), typeof(ComboBoxEditBase), typeof(ItemsEditBase))]
88
public static class MauiProgram
99
{
1010
public static MauiApp CreateMauiApp()

MyFinance/MyFinance.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
5757
<PackageReference Include="DevExpress.Maui.Controls" Version="24.1.1-alpha-24085" />
5858
<PackageReference Include="DevExpress.Maui.Editors" Version="24.1.1-alpha-24085" />
59-
<PackageReference Include="FmgLib.MauiMarkup" Version="8.*" />
59+
<PackageReference Include="FmgLib.MauiMarkup" Version="8.2.3-prev1.0.0" />
6060
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
6161
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.21" />
6262
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.21" />

MyFinance/Resources/Styles/AppStyles.cs

+42-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,49 @@ public class AppStyles
77
{
88
public static ResourceDictionary Default => new ResourceDictionary {
99

10+
// "TextEdit"
11+
12+
new Style<TextEdit>(e => e
13+
.LabelColor(DeepSkyBlue)
14+
.BorderColor(DeepSkyBlue)
15+
.FocusedBorderColor(DeepSkyBlue)
16+
.FocusedLabelColor(DeepSkyBlue)
17+
.CursorColor(DeepSkyBlue)
18+
.LabelFontSize(14)),
19+
20+
// "PasswordEdit"
21+
22+
new Style<PasswordEdit>(e => e
23+
.LabelColor(DeepSkyBlue)
24+
.BorderColor(DeepSkyBlue)
25+
.FocusedBorderColor(DeepSkyBlue)
26+
.FocusedLabelColor(DeepSkyBlue)
27+
.CursorColor(DeepSkyBlue)
28+
.LabelFontSize(14)),
29+
30+
// "CheckEdit"
31+
32+
new Style<CheckEdit>(e => e
33+
.LabelFontSize(12)
34+
.CheckBoxColor(DeepSkyBlue)
35+
.CheckedCheckBoxColor(DeepSkyBlue)
36+
.LabelVerticalAlignment(TextAlignment.Center)),
37+
38+
// "ComboBoxEdit"
39+
40+
new Style<ComboBoxEdit>(e => e
41+
.LabelColor(DeepSkyBlue)
42+
.BorderColor(DeepSkyBlue)
43+
.FocusedBorderColor(DeepSkyBlue)
44+
.FocusedLabelColor(DeepSkyBlue)
45+
.CursorColor(DeepSkyBlue)
46+
.LabelFontSize(14)),
47+
1048
// "ActivityIndicator"
1149

1250
new Style<ActivityIndicator>(e => e
13-
.Color(e => e.OnLight(AppColors.Primary).OnDark(Colors.White))),
51+
.Color(DeepSkyBlue)
52+
/*.Color(e => e.OnLight(AppColors.Primary).OnDark(Colors.White))*/),
1453

1554
// "IndicatorView"
1655

@@ -34,8 +73,8 @@ public class AppStyles
3473
// "Button"
3574

3675
new Style<Button>(e => e
37-
.TextColor(e => e.OnLight(Colors.White).OnDark(AppColors.Primary))
38-
.BackgroundColor(e => e.OnLight(AppColors.Primary).OnDark(Colors.White))
76+
.TextColor(Black)
77+
.BackgroundColor(DeepSkyBlue)
3978
.FontFamily("OpenSansRegular")
4079
.FontSize(14)
4180
.CornerRadius(8)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System.Windows.Input;
2+
3+
namespace MyFinance.ViewModels;
4+
5+
public partial class RegisterPageViewModel(IUserRepo repo) : BaseViewModel
6+
{
7+
[ObservableProperty]
8+
private User userModel = new()
9+
{
10+
Email = string.Empty,
11+
FirstName = string.Empty,
12+
LastName = string.Empty,
13+
Password = string.Empty
14+
};
15+
16+
[ObservableProperty]
17+
private bool isPopupShow = false;
18+
19+
[ObservableProperty]
20+
private bool isUserAdded = false;
21+
22+
public ICommand RegisterCommand => new Command(async () =>
23+
{
24+
if (UserModel == default!)
25+
return;
26+
27+
UserModel.IsActive = true;
28+
var result = await repo.InsertAsync(UserModel);
29+
30+
if (!result)
31+
{
32+
IsUserAdded = false;
33+
IsPopupShow = true;
34+
}
35+
else
36+
{
37+
IsUserAdded = true;
38+
IsPopupShow = true;
39+
await AppShell.Current.GoToAsync($"//{nameof(LoginPage)}");
40+
}
41+
});
42+
43+
public ICommand GoToLoginCommand => new Command(async () =>
44+
{
45+
await AppShell.Current.GoToAsync($"//{nameof(LoginPage)}");
46+
});
47+
48+
49+
}

0 commit comments

Comments
 (0)