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
32 changes: 26 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
## Submission description

_Use this area to describe your submission. Screenshots are appreciated and GIFs (with a hard "g") or video clips will get bonus points!_
I wanted to test RightToLeft

### What went well

_This is self-explanatory. Let us know what you liked about using the CarouselView when creating this submission._
I was surprised how RightToLeft is supported, When I set FlowDirection="RightToLeft", The first page was as expected,
Excellent job Xamarin team, Go Ahead

### What didn't go well

_What didn't go well, and why? How can we improve it? Please provide as much detail as possible!_

with VS2017, the app crashes immediatly, I couldn't fix it.
with VS2019, when i write as following, i get exception with "cast not valid" message:
<CarouselView FlowDirection="RightToLeft">
<CarouselView.ItemTemplate>
<DataTemplate>
<ViewCell>
//My template
</ViewCell>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>

but no crashed when i write as following:
<CarouselView FlowDirection="RightToLeft">
<CarouselView.ItemTemplate>
<DataTemplate>
//My template
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>

### Missing or desired things

_Fill this with any missing or desired things and how they impact you._
Nothing not mentioned by other PRs

### Anything else

_If we missed anything, feel free to mention it here._
Very good job, Go Ahead Xamarin

### Take out a survey for some goodies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Android.Support.Core.Utils">
<Version>28.0.0.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.3.0.778476-pre1" />
<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.1" />
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;

using Android.App;
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace CarouselViewChallenge.Droid
Expand All @@ -20,15 +15,8 @@ protected override void OnCreate(Bundle savedInstanceState)
base.OnCreate(savedInstanceState);

global::Xamarin.Forms.Forms.SetFlags("CollectionView_Experimental");
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.3.0.778476-pre1" />
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.3.0.778476-pre1" />
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
</ItemGroup>

<ItemGroup>
<Folder Include="Models\" />
<PackageReference Include="Xamarin.Forms" Version="4.3.0.778476-pre1" />
</ItemGroup>

<ItemGroup>
Expand Down
80 changes: 80 additions & 0 deletions CarouselViewChallenge/CarouselViewChallenge/Models/Article.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System.ComponentModel;

namespace CarouselViewChallenge.Models
{
public class Article : INotifyPropertyChanged
{
#region Properties
private string title;
public string Article_title
{
get
{
return title;
}

set
{
title = value;
onPropertyChange("Article_title");
}
}

private string imageurl;
public string Image
{
get
{
return imageurl;
}
set
{
imageurl = value;
onPropertyChange("Image");
}
}

private string category;
public string Category
{
get
{
return category;
}
set
{
category = value;
onPropertyChange("Category");
}
}

private string content;
public string Content
{
get
{
return content;
}
set
{
content = value;
onPropertyChange("Content");
}
}
#endregion

public Article()
{
}

public event PropertyChangedEventHandler PropertyChanged;

private void onPropertyChange(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using CarouselViewChallenge.Models;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace CarouselViewChallenge.ViewModels
{
public class ArticleViewModel : INotifyPropertyChanged
{
public ObservableCollection<Article> articles { get; set; }

public ArticleViewModel()
{
articles = new ObservableCollection<Article>();

for (int i = 0; i < 10; i++)
{
Article temp = new Article
{
Article_title = $"نص المقالة {i + 1}",
Category = $"التصنيف {i + 1}",
Image = @"https://hbrarabic.com/wp-content/uploads/2019/09/هارفارد-بزنس-ريفيو-الابتكار-المزعزع.jpg",
Content = this.getContent()
};

articles.Add(temp);
}
}

public event PropertyChangedEventHandler PropertyChanged;

private void onPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}

private string getContent()
{
return "هذا النص اختبار هذا النص اختبار هذا النص اختبار هذا النص اختبار هذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبارهذا النص اختبار";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,48 @@
<?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:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="CarouselViewChallenge.Views.CarouselViewChallengePage">
<ContentPage.Content>
<StackLayout BackgroundColor="#cfd8dc">
<Label Text="You can use this page for the CarouselView Challenge!" HorizontalOptions="Center" VerticalOptions="CenterAndExpand"/>
<Label Text="test"></Label>
<CarouselView x:Name="cvArticles"
FlowDirection="RightToLeft">
<CarouselView.ItemTemplate>
<DataTemplate>
<Frame IsClippedToBounds="False"
HasShadow="False"
Margin="5,3,5,3"
Padding="0.1,5,0.1,0.1"
BorderColor="Black"
BackgroundColor="#f0f1f1">
<StackLayout VerticalOptions="StartAndExpand"
Margin="0,0,0,15"
Padding="15,0,15,0">
<Image Aspect="AspectFill"
Source="{Binding Image}">
</Image>

<Label Text="{Binding Article_title}"
TextColor="#5f5f5f"
FontSize="Title">
</Label>

<Label TextColor="#C82502"
Text="{Binding Category}"
FontSize="Caption">
</Label>

<ScrollView>
<Label FontAttributes="Bold"
Margin="7,10,7,0"
Text="{ Binding Content }">
</Label>
</ScrollView>
</StackLayout>
</Frame>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

Expand All @@ -15,6 +10,9 @@ public partial class CarouselViewChallengePage : ContentPage
public CarouselViewChallengePage()
{
InitializeComponent();
ArticleViewModel vm = new ArticleViewModel();
BindingContext = vm;
this.cvArticles.ItemsSource = vm.articles;
}
}
}
Binary file added rtl.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.