Skip to content

Commit

Permalink
Updating Item Input to be a Display Prompt, also other changes becaus…
Browse files Browse the repository at this point in the history
…e mac
  • Loading branch information
Programming-With-Chris committed Aug 15, 2022
1 parent 7aeb6bd commit d362f44
Show file tree
Hide file tree
Showing 16 changed files with 246 additions and 63 deletions.
Binary file added .DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions ShoppingList/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="ShoppingList.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
Expand All @@ -14,10 +14,10 @@


<FlyoutItem FlyoutDisplayOptions="AsMultipleItems">
<ShellContent Title="Settings"
Icon="settings_outline.svg"
<ShellContent Title="Settings Test"
Route="SettingsView"
ContentTemplate="{DataTemplate views:SettingsView}"/>
<!-- Had to remove Icon, it was causing issues on IOS, Settings page wouldn't route-->

</FlyoutItem>

Expand Down
46 changes: 46 additions & 0 deletions ShoppingList/Drawable/CircularButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
namespace ShoppingList.Drawable;

public class CircularButton : IDrawable
{
public Color StrokeColor { get; set; } = Colors.DarkGrey;

public bool AreShadowsEnabled { get; set; } = true;

public Microsoft.Maui.Graphics.IImage Image { get; set; }

public int Width { get; set; } = 0;
public int Height { get; set; } = 0;

public void Draw(ICanvas canvas, RectF dirtyRect)
{
canvas.StrokeColor = StrokeColor;

if (AreShadowsEnabled)
canvas.EnableDefaultShadow();

var width = Width != 0 ? Width : dirtyRect.Width;
var height = Height != 0 ? Height : dirtyRect.Height;

var limitingDim = width > height ? height : width;
PointF centerOfCircle = new PointF(width / 2, height / 2);

// canvas.BlendMode = BlendMode.SourceOut;
canvas.FillColor = Colors.White;
canvas.FillCircle(centerOfCircle, limitingDim / 2);

if (Image != null)
{
ImagePaint imagePaint = new ImagePaint();
imagePaint.Image = this.Image;
canvas.SetFillPaint(imagePaint, RectF.Zero);

canvas.FillCircle(centerOfCircle, limitingDim / 2);
}


// canvas.DrawImage(Image, centerOfCircle.X, centerOfCircle.Y, limitingDim, limitingDim);

}
}

2 changes: 1 addition & 1 deletion ShoppingList/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
global using System.Threading.Tasks;
global using CommunityToolkit.Mvvm.ComponentModel;
global using CommunityToolkit.Mvvm.Input;
global using Microsoft.Data.Sqlite;
global using SQLitePCL;
global using SQLite;
global using ShoppingList.Model;
global using ShoppingList.Services;
global using ShoppingList.ViewModels;
global using ShoppingList.Drawable;
global using SQLiteNetExtensions.Attributes;
global using CommunityToolkit.Diagnostics;

Expand Down
14 changes: 14 additions & 0 deletions ShoppingList/Platforms/iOS/Entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<string>group.dev.programmingwithchris.ShoppingList</string>
<key>com.apple.developer.default-data-protection</key>
<string>NSFileProtectionComplete</string>
<key>com.apple.security.inherit</key>
<true/>
<key>get-task-allow</key>
<true/>
</dict>
</plist>
4 changes: 4 additions & 0 deletions ShoppingList/Platforms/iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleIdentifier</key>
<string>dev.programmingwithchris.ShoppingList</string>
<key>Build</key>
<integer>1</integer>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
</dict>
Expand Down
6 changes: 6 additions & 0 deletions ShoppingList/Resources/APIs/krogerapiconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ClientId": "shoppinglistbuddy-prod-a62f2a49c096edda094c6646e8fe16023424942672257304802",
"ClientSecret": "qsX3hImoIt77GDhqJP12bznpqxSfu8BPgSvwSJZY",
"RedirectUri": "https://dev.programmingwithchris/shoppinglist",
"KrogerUrl": "https://api.kroger.com/v1/"
}
1 change: 1 addition & 0 deletions ShoppingList/Resources/Images/plus_solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions ShoppingList/Services/DatabaseHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ public class DatabaseHandler
/// </summary>
public DatabaseHandler()
{
_pathToDb = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "shoppinglist_sqlite.db");
//#if ios
_pathToDb = Path.Combine (
Environment.GetFolderPath (Environment.SpecialFolder.Personal),
"database.db3");
//#else
//_pathToDb = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "shoppinglist_sqlite.db");
//#endif

_db = new SQLiteConnection(_pathToDb);
_db.CreateTable<Item>();
_db.CreateTable<ItemLocationData>();
Expand Down Expand Up @@ -106,7 +113,7 @@ public DatabaseHandler(string newDBName)
if (returnList.Count > 0)
return returnList;

throw new Exception("Nothing was returned from query on Table = " + typeof(T).Name + " with Parent Id = ?" + id);
throw new Exception("Nothing was returned from query on Table = " + typeof(T).Name + " with Parent Id = " + id);
}

/// <summary>
Expand Down
44 changes: 31 additions & 13 deletions ShoppingList/ShoppingList.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net6.0-ios;</TargetFrameworks>
<!-- <TargetFrameworks>net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>-->
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
Expand All @@ -19,7 +19,7 @@
<ApplicationTitle>ShoppingList</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.shoppinglist</ApplicationId>
<ApplicationId>dev.programmingwithchris.ShoppingList</ApplicationId>
<ApplicationIdGuid>C035DD89-2C0B-4F47-AF16-ACCD775A25F9</ApplicationIdGuid>

<!-- Versions -->
Expand Down Expand Up @@ -54,6 +54,9 @@

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
<MauiAsset Include="Resources\APIs\krogerapiconfig.json">
<LogicalName>krogerapiconfig.json</LogicalName>
</MauiAsset>
</ItemGroup>

<ItemGroup>
Expand All @@ -62,21 +65,25 @@
<MauiCss Remove="Tests\**" />
<MauiXaml Remove="Tests\**" />
<None Remove="Tests\**" />
<None Remove="SQLiteNetExtensions" />
<None Remove="Microsoft.Data.Sqlite.Core" />
<None Remove="sqlite-net-static" />
<None Remove="Drawable\" />
<None Remove="Resources\Images\plus_solid.svg" />
<None Remove="Resources\APIs\krogerapiconfig.json" />
<None Remove="Platforms\iOS\Entitlements.plist" />
<None Remove="Platforms\iOS\Info.plist" />
</ItemGroup>

<ItemGroup>
<None Remove="Resources\Images\ellipsis_vertical_outline.svg" />
<None Remove="Resources\Raw\krogerapiconfig-test.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.0.0-preview4" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0-preview4" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.7" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="SkiaSharp" Version="2.88.0" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="SQLiteNetExtensions" Version="2.1.0" />
<PackageReference Include="sqlite-net-static" Version="1.8.116" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -123,12 +130,23 @@

<ItemGroup>
<Folder Include="Resources\APIs\" />
<Folder Include="Drawable\" />
</ItemGroup>

<ItemGroup>
<MauiAsset Update="Resources\Raw\krogerapiconfig-test.json">
<LogicalName>%(RecursiveDir)%(Filename)%(Extension)</LogicalName>
</MauiAsset>
<EmbeddedResource Include="Platforms\iOS\Entitlements.plist" />
<EmbeddedResource Include="Platforms\iOS\Info.plist" />
<EmbeddedResource Include="Resources\Images\plus_solid.svg" />
</ItemGroup>

<!-- <PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
<CodesignKey>Apple Development: Created via API (T65FC7WCJW)</CodesignKey>
<CodesignProvision>ShoppingListDev</CodesignProvision>
<ArchiveOnBuild>true</ArchiveOnBuild>
<TcpPort>58181</TcpPort>
</PropertyGroup>-->
<ItemGroup>
<MauiImage Remove="Resources\Images\plus_solid.svg" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions ShoppingList/View/ItemInput.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
x:DataType="viewmodel:ItemInputViewModel"
x:Class="ShoppingList.ItemInput"
Shell.PresentationMode="Animated"
Padding="50"
>

<Grid ColumnDefinitions="*,*,*,*,Auto,Auto"
Expand Down
8 changes: 0 additions & 8 deletions ShoppingList/View/SettingsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,5 @@ public SettingsView(SettingsViewModel settingsViewModel)
BindingContext = settingsViewModel;

}

/* public void OnUserListNameCompleted(object sender, EventArgs e)
{
string name = ((Entry)sender).Text;
Console.WriteLine(name);
Shell.Current.DisplayAlert("Your list name:", name, "Ok");
}*/
}

4 changes: 2 additions & 2 deletions ShoppingList/View/StoreFinder.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public StoreFinder(StoreFinderViewModel storeFinderViewModel)

public void OnSearchButtonPressed(object sender, EventArgs e)
{
var test = ((SearchBar)sender).Text;
_sfvm.DoSearchQuery(test);
var zipCode = ((SearchBar)sender).Text;
_sfvm.DoSearchQuery(zipCode);
//_ulvm.ItemWasChecked(itemThatWasClicked);
}
}
Expand Down
55 changes: 32 additions & 23 deletions ShoppingList/View/UserListDetails.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,29 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:model="clr-namespace:ShoppingList.Model"
xmlns:viewmodel="clr-namespace:ShoppingList.ViewModels"
xmlns:view="clr-namespace:ShoppingList"
xmlns:drawables="clr-namespace:ShoppingList.Drawable"
x:DataType="viewmodel:UserListDetailViewModel"
x:Class="ShoppingList.UserListDetails"
Title="{Binding Title}">

<ContentPage.Resources>
<drawables:CircularButton x:Key="circularButton"/>
</ContentPage.Resources>

<Shell.BackButtonBehavior>
<BackButtonBehavior Command="{Binding GoBackToListScreenCommand}"
/>
</Shell.BackButtonBehavior>


<Grid ColumnDefinitions="*,*"
ColumnSpacing="5"
RowDefinitions="*,Auto">
<Grid ColumnDefinitions="*,*,*"
ColumnSpacing="3"
RowDefinitions="*,*,Auto">

<RefreshView Grid.ColumnSpan="3"
Command="{Binding RefreshUserListDetailScreenCommand}"
<RefreshView Grid.ColumnSpan="3" Command="{Binding RefreshUserListDetailScreenCommand}"
CommandParameter="UserListCollectionView"
IsRefreshing="{Binding IsRefreshing}">
IsRefreshing="{Binding IsRefreshing}"
Grid.Row="0">
<CollectionView ItemsSource="{Binding UserList.Items}"
CanReorderItems="True"
SelectionMode="None"
Expand All @@ -30,10 +34,11 @@
<CollectionView.ItemTemplate >
<DataTemplate x:DataType="model:Item">
<Grid Padding="10"
ColumnDefinitions="*,*"
ColumnDefinitions="*,*,*"
RowDefinitions="*,Auto">
<Frame Grid.ColumnSpan="3"
<Frame Grid.ColumnSpan="2"
Padding="10"
Margin="0,0,0,10"
x:Name="ItemFrame"
BindingContext="{Binding .}">
<Frame.GestureRecognizers>
Expand All @@ -44,7 +49,7 @@
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:UserListDetailViewModel}}, Path=DeleteItemCommand}"
Direction="Right"/>
</Frame.GestureRecognizers>
<Grid ColumnDefinitions="Auto,*,*,*,Auto"
<Grid ColumnDefinitions="Auto,*,*"
RowDefinitions="*,Auto"
Grid.ColumnSpan="1"
Grid.RowSpan="2"
Expand All @@ -64,7 +69,9 @@
Grid.RowSpan="1"/>
<Label Text="{Binding Aisle}"
Grid.Row="1"
Grid.Column="3"/>
Grid.Column="2"
Grid.ColumnSpan="2"
/>
<!--<VerticalStackLayout Grid.Column="5"
Grid.Row="0"
HorizontalOptions="End">
Expand All @@ -90,18 +97,20 @@
</CollectionView>
</RefreshView>

<Button Text="Create New Item"
Command="{Binding CreateItemCommand}"
CommandParameter="{Binding UserList}"
Grid.Row="2"
Margin="8"/>

<Button Text="Back to My Lists"
Command="{Binding GoBackToListScreenCommand}"
CommandParameter="{Binding UserList}"
Grid.Row="2"
Grid.Column="3"
Margin="8"/>
<GraphicsView Drawable="{StaticResource circularButton}"
Grid.Row="2"
Grid.Column="0"
x:Name="CircularButton"
WidthRequest="100"
HeightRequest="100"
BackgroundColor="Transparent"
>
<GraphicsView.GestureRecognizers>
<TapGestureRecognizer Command="{Binding NewItemDialogCommand}"/>

</GraphicsView.GestureRecognizers>
</GraphicsView>

</Grid>

</ContentPage>
Loading

0 comments on commit d362f44

Please sign in to comment.