-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
79 changed files
with
792 additions
and
425 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
62 changes: 62 additions & 0 deletions
62
Masa.Blazor.ProApp.Rcl/Components/DateDigitalClockSheet.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<MBottomSheet Value="Show" | ||
ValueChanged="ShowChanged"> | ||
<div class="d-flex"> | ||
<MButton Text Color="secondary" | ||
OnClick="@HandleOnCancel"> | ||
Cancel | ||
</MButton> | ||
<MSpacer/> | ||
<MButton Text Color="primary" | ||
OnClick="@HandleOnConfirm"> | ||
Confirm | ||
</MButton> | ||
</div> | ||
<PDateDigitalClockPickerView Value="_internalDate" | ||
ValueChanged="InternalDateChanged" | ||
TValue="DateTime" | ||
TimeFormat="TimeFormat.Hr24"> | ||
</PDateDigitalClockPickerView> | ||
</MBottomSheet> | ||
|
||
@code { | ||
|
||
[Parameter] public bool Show { get; set; } | ||
[Parameter] public EventCallback<bool> ShowChanged { get; set; } | ||
[Parameter] public DateTime Value { get; set; } | ||
[Parameter] public EventCallback<DateTime> ValueChanged { get; set; } | ||
|
||
private DateTime _internalDate; | ||
private bool _previousShow; | ||
|
||
protected override void OnParametersSet() | ||
{ | ||
base.OnParametersSet(); | ||
|
||
if (_previousShow != Show) | ||
{ | ||
_previousShow = Show; | ||
|
||
if (Show) | ||
{ | ||
_internalDate = Value; | ||
} | ||
} | ||
} | ||
|
||
private void InternalDateChanged(DateTime date) | ||
{ | ||
_internalDate = date; | ||
} | ||
|
||
private void HandleOnCancel() | ||
{ | ||
ShowChanged.InvokeAsync(false); | ||
} | ||
|
||
private async Task HandleOnConfirm() | ||
{ | ||
await ValueChanged.InvokeAsync(_internalDate); | ||
_ = ShowChanged.InvokeAsync(false); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Masa.Blazor.ProApp.Rcl.Models; | ||
using SQLite; | ||
|
||
namespace Masa.Blazor.ProApp.Rcl.Data; | ||
|
||
public class ProDatabase | ||
{ | ||
public const string DatabaseFilename = "proapp.db"; | ||
|
||
public const SQLiteOpenFlags Flags = | ||
// open the database in read/write mode | ||
SQLiteOpenFlags.ReadWrite | | ||
// create the database if it doesn't exist | ||
SQLiteOpenFlags.Create | | ||
// enable multi-threaded database access | ||
SQLiteOpenFlags.SharedCache; | ||
|
||
// public static string DatabasePath => | ||
// Path.Combine(FileSystem.AppDataDirectory, DatabaseFilename); | ||
|
||
private SQLiteAsyncConnection? Database { get; set; } | ||
|
||
[MemberNotNull(nameof(Database))] | ||
async Task InitAsync() | ||
{ | ||
if (Database is not null) | ||
{ | ||
return; | ||
} | ||
|
||
Database = new SQLiteAsyncConnection(DatabaseFilename, Flags); | ||
await Database.CreateTableAsync<TodoTask>(); | ||
} | ||
|
||
public async Task<int> CreateTaskAsync(TodoTask task) | ||
{ | ||
await InitAsync(); | ||
return await Database.InsertAsync(task); | ||
} | ||
|
||
public async Task UpdateTaskAsync(TodoTask task) | ||
{ | ||
await InitAsync(); | ||
await Database.UpdateAsync(task); | ||
} | ||
|
||
public async Task<List<TodoTask>> GetTasksAsync(int page, int pageSize, DateTime dateTime = default) | ||
{ | ||
await InitAsync(); | ||
|
||
var table = Database.Table<TodoTask>(); | ||
|
||
if (dateTime != default) | ||
{ | ||
table = table.Where(u => u.DueAt.Date == dateTime.Date); | ||
} | ||
|
||
return await table | ||
.Skip((page - 1) * pageSize) | ||
.Take(pageSize) | ||
.ToListAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using SQLite; | ||
|
||
namespace Masa.Blazor.ProApp.Rcl.Models; | ||
|
||
public class TodoTask | ||
{ | ||
public TodoTask() | ||
{ | ||
DueAt = DateTime.Today; | ||
} | ||
|
||
[PrimaryKey, AutoIncrement] public int Id { get; set; } | ||
|
||
[Required] [Indexed] public string? Title { get; set; } | ||
|
||
public string? Description { get; set; } | ||
|
||
[Required] public DateTime DueAt { get; set; } | ||
|
||
public TodoTaskPriority Priority { get; set; } | ||
|
||
public bool Important { get; set; } | ||
|
||
public bool Completed { get; set; } | ||
|
||
public string? Tags { get; set; } | ||
} | ||
|
||
public enum TodoTaskPriority | ||
{ | ||
Default, | ||
Low, | ||
Medium, | ||
High | ||
} |
File renamed without changes.
Oops, something went wrong.