feature: shortcut

This commit is contained in:
2022-03-17 20:29:27 +08:00
parent 60f7824cb5
commit ef5e91aad1
18 changed files with 118 additions and 36 deletions

View File

@@ -13,6 +13,7 @@ namespace Billing
{
public class App : Application
{
internal const string NewBillAction = "/newbill";
private const string SaveLocationKey = nameof(SaveLocationKey);
public static AppTheme CurrentTheme { get; private set; }
@@ -21,17 +22,27 @@ namespace Billing
public static List<Account> Accounts => accounts ??= new List<Account>();
public static List<Category> Categories => categories ??= new List<Category>();
public static bool SaveLocation => saveLocation;
public static string MainRoute => mainRoute;
private static List<Bill> bills;
private static List<Account> accounts;
private static List<Category> categories;
private static bool saveLocation;
private static string mainRoute;
private string initialUrl;
public App(string url = null)
{
initialUrl = url;
if (url == NewBillAction)
{
mainRoute = "//Bills/Details";
}
else
{
mainRoute = "//Bills";
initialUrl = url;
}
CurrentCulture = new PlatformCulture();
InitResources();

View File

@@ -1,3 +1,4 @@
using Billing.Views;
using Xamarin.Forms;
namespace Billing
@@ -6,6 +7,8 @@ namespace Billing
{
public MainShell()
{
Routing.RegisterRoute("Bills/Details", typeof(AddBillPage));
InitializeComponent();
}
}

View File

@@ -14,7 +14,7 @@ namespace Billing
{
await App.InitializeData();
await Shell.Current.GoToAsync("//Bills");
await Shell.Current.GoToAsync(App.MainRoute);
}
}
}

View File

@@ -38,6 +38,7 @@ namespace Billing.Store
catch (Exception ex)
{
Helper.Error("database.close", ex);
return false;
}
try
{
@@ -54,12 +55,13 @@ namespace Billing.Store
SQLiteOpenFlags.ReadWrite |
SQLiteOpenFlags.Create |
SQLiteOpenFlags.SharedCache);
return true;
}
catch (Exception ex)
{
Helper.Error("database.connect", ex);
return false;
}
return true;
}
public static readonly AsyncLazy<StoreHelper> Instance = new(async () =>

View File

@@ -70,6 +70,7 @@ namespace Billing.Views
private CancellationTokenSource tokenSource;
private Location location;
public AddBillPage() : this(DateTime.Today) { }
public AddBillPage(DateTime date)
{
createDate = date;

View File

@@ -13,25 +13,24 @@
Shell.TabBarIsVisible="True">
<Shell.TitleView>
<StackLayout Orientation="Horizontal" Spacing="10">
<Grid ColumnSpacing="10" ColumnDefinitions="30, *, 30">
<ui:TintImageButton Source="left.png" WidthRequest="20" HeightRequest="20"
VerticalOptions="Center" HorizontalOptions="Start"
VerticalOptions="Center" HorizontalOptions="Center"
Command="{Binding LeftCommand}"/>
<Label Text="{Binding Title}"
<Label Grid.Column="1" Text="{Binding Title}"
TextColor="{DynamicResource PrimaryColor}"
FontSize="{OnPlatform Android=20, iOS=18}"
FontFamily="{x:Static ui:Definition.SemiBoldFontFamily}"
VerticalOptions="Center"
HorizontalOptions="FillAndExpand"
HorizontalTextAlignment="Center">
HorizontalOptions="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding FilterCommand}"/>
</Label.GestureRecognizers>
</Label>
<ui:TintImageButton Source="right.png" WidthRequest="20" HeightRequest="20"
VerticalOptions="Center" HorizontalOptions="End"
<ui:TintImageButton Grid.Column="2" Source="right.png" WidthRequest="20" HeightRequest="20"
VerticalOptions="Center" HorizontalOptions="Center"
Command="{Binding RightCommand}"/>
</StackLayout>
</Grid>
</Shell.TitleView>
<!--<ContentPage.ToolbarItems>