main
syneffort 2 years ago
parent ae58254191
commit 64b8b8b993
  1. BIN
      XamarinStudy/Resource/Image/splash.png
  2. 2
      XamarinStudy/XamarinStudy/XamarinStudy.Android/MainActivity.cs
  3. 8
      XamarinStudy/XamarinStudy/XamarinStudy.Android/Properties/AndroidManifest.xml
  4. 11
      XamarinStudy/XamarinStudy/XamarinStudy.Android/Resources/Resource.designer.cs
  5. BIN
      XamarinStudy/XamarinStudy/XamarinStudy.Android/Resources/drawable/splash.png
  6. 6
      XamarinStudy/XamarinStudy/XamarinStudy.Android/XamarinStudy.Android.csproj
  7. BIN
      XamarinStudy/XamarinStudy/XamarinStudy.UWP/Assets/SplashScreen.scale-100.png
  8. BIN
      XamarinStudy/XamarinStudy/XamarinStudy.UWP/Assets/SplashScreen.scale-125.png
  9. BIN
      XamarinStudy/XamarinStudy/XamarinStudy.UWP/Assets/SplashScreen.scale-150.png
  10. BIN
      XamarinStudy/XamarinStudy/XamarinStudy.UWP/Assets/SplashScreen.scale-200.png
  11. BIN
      XamarinStudy/XamarinStudy/XamarinStudy.UWP/Assets/SplashScreen.scale-400.png
  12. 2
      XamarinStudy/XamarinStudy/XamarinStudy.UWP/XamarinStudy.UWP.csproj
  13. 2
      XamarinStudy/XamarinStudy/XamarinStudy/App.xaml.cs
  14. 27
      XamarinStudy/XamarinStudy/XamarinStudy/Models/Toy.cs
  15. 18
      XamarinStudy/XamarinStudy/XamarinStudy/Views/ToyDetailPage.xaml
  16. 22
      XamarinStudy/XamarinStudy/XamarinStudy/Views/ToyDetailPage.xaml.cs
  17. 20
      XamarinStudy/XamarinStudy/XamarinStudy/Views/ToyMartPage.xaml
  18. 37
      XamarinStudy/XamarinStudy/XamarinStudy/Views/ToyMartPage.xaml.cs
  19. 22
      XamarinStudy/XamarinStudy/XamarinStudy/Views/ToyOrderPage.xaml
  20. 27
      XamarinStudy/XamarinStudy/XamarinStudy/Views/ToyOrderPage.xaml.cs
  21. 6
      XamarinStudy/XamarinStudy/XamarinStudy/XamarinStudy.csproj

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

@ -7,7 +7,7 @@ using Android.OS;
namespace XamarinStudy.Droid
{
[Activity(Label = "XamarinStudy", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]
[Activity(Label = "XamarinStudy", Icon = "@drawable/droid", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.xamarinstudy">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
<application android:label="XamarinStudy.Android" android:theme="@style/MainTheme"></application>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.xamarinstudy" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
<application android:label="XamarinStudy.Android" android:theme="@style/MainTheme" android:icon="@drawable/droid"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

@ -16664,16 +16664,19 @@ namespace XamarinStudy.Droid
public const int preference_list_divider_material = 2131165327;
// aapt resource value: 0x7F070090
public const int test_custom_background = 2131165328;
public const int splash = 2131165328;
// aapt resource value: 0x7F070091
public const int tooltip_frame_dark = 2131165329;
public const int test_custom_background = 2131165329;
// aapt resource value: 0x7F070092
public const int tooltip_frame_light = 2131165330;
public const int tooltip_frame_dark = 2131165330;
// aapt resource value: 0x7F070093
public const int xamarin_logo = 2131165331;
public const int tooltip_frame_light = 2131165331;
// aapt resource value: 0x7F070094
public const int xamarin_logo = 2131165332;
static Drawable()
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

@ -17,7 +17,7 @@
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v12.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v13.0</TargetFrameworkVersion>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<AndroidUseAapt2>true</AndroidUseAapt2>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
@ -33,6 +33,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
<EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -95,5 +96,8 @@
<ItemGroup>
<AndroidResource Include="Resources\drawable\droid.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\splash.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 46 KiB

@ -105,6 +105,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="Assets\droid.png" />
<Content Include="Assets\SplashScreen.scale-125.png" />
<Content Include="Assets\SplashScreen.scale-150.png" />
<Content Include="Properties\Default.rd.xml" />
<Content Include="Assets\LargeTile.scale-100.png" />
<Content Include="Assets\LargeTile.scale-200.png" />

@ -57,7 +57,7 @@ namespace XamarinStudy
//MainPage = new SampleListViewPage();
MainPage = new ToyMartPage();
MainPage = new NavigationPage(new ToyMartPage());
}
protected override void OnStart()

@ -1,20 +1,41 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
namespace XamarinStudy.Models
{
internal class Toy
public class Toy : INotifyPropertyChanged
{
public enum TOY_CATEGORY { Robot, Car, Plane, Figure, Block }
public string Name { get; set; }
public int Price { get; set; }
public int Count { get; set; }
public int Count { get; set; } = 1;
public string Image { get => $"{this.Name}.png"; }
public bool Checked { get; set; }
public TOY_CATEGORY Category { get; set; }
private bool isChecked;
public bool IsChecked
{
get
{
return isChecked;
}
set
{
isChecked = value;
OnPropertyChanged("IsChecked");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
class KindOf<K, T> : List<T>

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:common="clr-namespace:XamarinStudy.Commons;assembly=XamarinStudy"
x:Class="XamarinStudy.Views.ToyDetailPage">
<ContentPage.Resources>
<ResourceDictionary>
<common:ValueConverter x:Key="cvt"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<StackLayout>
<Image Source="{Binding Image, Converter={StaticResource cvt}}" HeightRequest="250"/>
<Label Text="{Binding Name}" FontSize="Large" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" HorizontalOptions="FillAndExpand"/>
<Label Text="{Binding Price}" FontSize="Medium" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" HorizontalOptions="FillAndExpand"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XamarinStudy.Models;
namespace XamarinStudy.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ToyDetailPage : ContentPage
{
public ToyDetailPage(Toy toy)
{
InitializeComponent();
this.BindingContext = toy;
}
}
}

@ -2,22 +2,28 @@
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:common="clr-namespace:XamarinStudy.Commons;assembly=XamarinStudy"
x:Class="XamarinStudy.Views.ToyMartPage">
x:Class="XamarinStudy.Views.ToyMartPage"
Title="Toy Mart">
<ContentPage.Resources>
<ResourceDictionary>
<common:ValueConverter x:Key="cvt"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.ToolbarItems>
<ToolbarItem x:Name="orderToolbarItem" Text="Order" Clicked="orderToolbarItem_Clicked"/>
<ToolbarItem x:Name="unselectAllToolbarItem" Text="Unselect All" Clicked="unselectAllToolbarItem_Clicked"/>
</ContentPage.ToolbarItems>
<ContentPage.Content>
<ListView x:Name="menuListView" ItemsSource="{Binding .}" HasUnevenRows="True" IsGroupingEnabled="True" GroupDisplayBinding="{Binding Title}">
<ListView x:Name="menuListView" ItemsSource="{Binding .}"
HasUnevenRows="True" IsGroupingEnabled="True" GroupDisplayBinding="{Binding Title}"
IsPullToRefreshEnabled="True" Refreshing="menuListView_Refreshing"
ItemTapped="menuListView_ItemTapped">
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" BackgroundColor="DarkSlateBlue" Padding="2 10">
<Label Text="{Binding Title}" FontSize="Large" TextColor="White"/>
<Label Text=": " FontSize="Large" TextColor="White"/>
<StackLayout Orientation="Horizontal" BackgroundColor="DarkSlateBlue">
<Label Text="{Binding Title}" HorizontalOptions="StartAndExpand" FontSize="Large" TextColor="White"/>
<Label Text="{Binding Count}" FontSize="Large" TextColor="White"/>
<Label Text="ea" FontSize="Large" TextColor="White"/>
</StackLayout>
</ViewCell>
</DataTemplate>
@ -29,7 +35,7 @@
<Image Source="{Binding Image, Converter={StaticResource cvt}}" WidthRequest="50" HeightRequest="50"/>
<Label Text="{Binding Name}" FontSize="Large" VerticalTextAlignment="Center" HorizontalOptions="FillAndExpand"/>
<Label Text="{Binding Price}" FontSize="Medium" VerticalTextAlignment="Center" HorizontalOptions="FillAndExpand"/>
<CheckBox IsChecked="{Binding Checked}"/>
<CheckBox IsChecked="{Binding IsChecked}"/>
</StackLayout>
</ViewCell>
</DataTemplate>

@ -25,5 +25,42 @@ namespace XamarinStudy.Views
//menuListView.ItemsSource = ToyRepository.ToyList;
menuListView.ItemsSource = ToyRepository.ToyListKindOf;
}
private void menuListView_ItemTapped(object sender, ItemTappedEventArgs e)
{
Navigation.PushAsync(new ToyDetailPage((Toy)e.Item));
}
private void orderToolbarItem_Clicked(object sender, EventArgs e)
{
List<Toy> selected = ToyRepository.ToyListKindOf.SelectMany(t => t).Where(t => t.IsChecked).ToList();
if (selected.Count < 1)
{
DisplayAlert("Alert", "Please select the items.", "OK");
return;
}
Navigation.PushAsync(new ToyOrderPage(selected));
}
private void menuListView_Refreshing(object sender, EventArgs e)
{
List<Toy> selected = ToyRepository.ToyListKindOf.SelectMany(t => t).Where(t => t.IsChecked).ToList();
foreach (Toy toy in selected)
{
toy.IsChecked = false;
}
menuListView.EndRefresh();
}
private void unselectAllToolbarItem_Clicked(object sender, EventArgs e)
{
List<Toy> selected = ToyRepository.ToyListKindOf.SelectMany(t => t).Where(t => t.IsChecked).ToList();
foreach (Toy toy in selected)
{
toy.IsChecked = false;
}
}
}
}

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamarinStudy.Views.ToyOrderPage">
<ContentPage.Content>
<StackLayout>
<ListView x:Name="orderList" ItemsSource="{Binding .}" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal">
<Label Text="{Binding Name}" VerticalTextAlignment="Center" HorizontalOptions="StartAndExpand" FontSize="Large"/>
<Entry x:Name="countEntry" Text="{Binding Count}" Keyboard="Numeric" WidthRequest="150" HorizontalOptions="EndAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button x:Name="orderButton" Text="Order" FontSize="Large" Clicked="orderButton_Clicked"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XamarinStudy.Models;
namespace XamarinStudy.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ToyOrderPage : ContentPage
{
public ToyOrderPage(List<Toy> toys)
{
InitializeComponent();
orderList.BindingContext = toys;
}
private void orderButton_Clicked(object sender, EventArgs e)
{
DisplayAlert("Order finished", "Your order has been successfully processed.", "OK");
}
}
}

@ -110,8 +110,14 @@
<EmbeddedResource Update="Views\SampleToolbarPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\ToyDetailPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\ToyMartPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\ToyOrderPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>
Loading…
Cancel
Save