Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<AndroidUseAapt2>true</AndroidUseAapt2>
Expand Down Expand Up @@ -96,7 +95,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CarouselViewChallenge\CarouselViewChallenge.csproj">
<Project>{1AD32EAF-CE1F-497F-8598-87F19CDA3D10}</Project>
<Project>{A9F8B9B3-719F-4F40-9044-924E7B921409}</Project>
<Name>CarouselViewChallenge</Name>
</ProjectReference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<?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.carouselviewchallenge">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="CarouselViewChallenge.Android"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="CarouselViewChallenge.Android"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\CarouselViewChallenge\CarouselViewChallenge.csproj">
<Project>{1AD32EAF-CE1F-497F-8598-87F19CDA3D10}</Project>
<Project>{A9F8B9B3-719F-4F40-9044-924E7B921409}</Project>
<Name>CarouselViewChallenge</Name>
</ProjectReference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<ItemGroup>
<Folder Include="Models\" />
<Folder Include="Resources\" />
</ItemGroup>

<ItemGroup>
Expand All @@ -20,9 +21,20 @@
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\sample-rose-florentina.jpg" />
<EmbeddedResource Include="Resources\sample-rose-honeycaramel.jpg" />
<EmbeddedResource Include="Resources\sample-rose-hotchocolate.jpg" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Views\CarouselViewChallengePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Remove="Resources\sample-rose-florentina.jpg" />
<None Remove="Resources\sample-rose-honeycaramel.jpg" />
<None Remove="Resources\sample-rose-hotchocolate.jpg" />
<None Remove="Screenshots\after.png" />
</ItemGroup>
</Project>
17 changes: 17 additions & 0 deletions CarouselViewChallenge/CarouselViewChallenge/Models/Plant.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;

namespace CarouselViewChallenge.Models
{
public class Plant
{
public string Name { get; set; }
public string Type { get; set; }
public string FlowerDate { get; set; }
public string FruitDate { get; set; }
public string HardinessZone { get; set; }
public string Description { get; set; }
public List<ImageSource> Images { get; set; }
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using CarouselViewChallenge.Models;

namespace CarouselViewChallenge.ViewModels
{
public class CarouselViewChallengePageViewModel
{
public Plant Plant { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,59 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="CarouselViewChallenge.Views.CarouselViewChallengePage">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Modify"/>
</ContentPage.ToolbarItems>
<ContentPage.Content>
<StackLayout BackgroundColor="#cfd8dc">
<Label Text="You can use this page for the CarouselView Challenge!" HorizontalOptions="Center" VerticalOptions="CenterAndExpand"/>
</StackLayout>
<ScrollView Margin="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="500"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
<Label Text="{Binding Plant.Name}" HorizontalTextAlignment="Center" FontSize="24" FontAttributes="Bold" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"/>

<CarouselView ItemsSource="{Binding Plant.Images}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<CarouselView.ItemTemplate>
<DataTemplate>
<StackLayout BackgroundColor="LightGray">
<Frame BorderColor="#00857D" Margin="8" CornerRadius="6" HasShadow="True" VerticalOptions="CenterAndExpand">
<Image Source="{Binding .}" Aspect="AspectFill"/>
</Frame>
</StackLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
<Label Text="种类" FontAttributes="Bold" Grid.Row="2" Grid.Column="0"/>
<Label Text="{Binding Plant.Type}" Grid.Row="2" Grid.Column="1"/>
<Label Text="花期" FontAttributes="Bold" Grid.Row="3" Grid.Column="0"/>
<Label Text="{Binding Plant.FlowerDate}" Grid.Row="3" Grid.Column="1"/>
<Label Text="花色" FontAttributes="Bold" Grid.Row="4" Grid.Column="0"/>
<StackLayout Orientation="Horizontal" Grid.Row="4" Grid.Column="1" HeightRequest="21">
<BoxView BackgroundColor="#e3051b" HeightRequest="18" WidthRequest="18" CornerRadius="6" Margin="1"
VerticalOptions="Center" HorizontalOptions="Start"/>
<BoxView BackgroundColor="#d12f02" HeightRequest="18" WidthRequest="18" CornerRadius="6" Margin="1"
VerticalOptions="Center" HorizontalOptions="Start"/>
<BoxView BackgroundColor="PaleVioletRed" HeightRequest="18" WidthRequest="18" CornerRadius="6" Margin="1"
VerticalOptions="Center" HorizontalOptions="Start"/>
</StackLayout>
<Label Text="果期" FontAttributes="Bold" Grid.Row="5" Grid.Column="0"/>
<Label Text="{Binding Plant.FruitDate}" Grid.Row="5" Grid.Column="1"/>
<Label Text="耐寒区" FontAttributes="Bold" Grid.Row="6" Grid.Column="0"/>
<Label Text="{Binding Plant.HardinessZone}" Grid.Row="6" Grid.Column="1"/>
<Label Text="{Binding Plant.Description}"
VerticalOptions="Start" HorizontalOptions="Start" Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="2"/>
</Grid>
</ScrollView>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using CarouselViewChallenge.Models;
using CarouselViewChallenge.ViewModels;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

Expand All @@ -12,9 +13,69 @@ namespace CarouselViewChallenge.Views
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CarouselViewChallengePage : ContentPage
{
public CarouselViewChallengePageViewModel VM { get; set; }

public CarouselViewChallengePage()
{
InitializeComponent();

VM = new CarouselViewChallengePageViewModel();
VM.Plant = new Plant
{
Name = "Florentina",
Type = "Climbing Rose",
FlowerDate = "3,4,5",
FruitDate = "6,7,8",
HardinessZone = "Zone 4-9",
Description = "佛罗伦蒂娜(佛罗伦萨、Florentina),德国, 2002,红色花,黄色花蕊。大花复瓣(26-40),杯型过渡至平坦花,多季开放。约两米,宽度约一米,耐寒。",
Images = new List<ImageSource>
{
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-florentina.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-honeycaramel.jpg"),
ImageSource.FromResource("CarouselViewChallenge.Resources.sample-rose-hotchocolate.jpg"),
}
};

BindingContext = VM;
}
}
}