Skip to content

Commit 82b315b

Browse files
authored
Merge pull request #34 from brminnick/master
Updated to Xamarin.Forms 2.3.4
2 parents e4f2330 + 86b0dae commit 82b315b

File tree

7 files changed

+2661
-2648
lines changed

7 files changed

+2661
-2648
lines changed

src/CustomLayouts/PagerIndicatorTabs.cs

Lines changed: 162 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -6,153 +6,167 @@
66

77
namespace CustomLayouts
88
{
9-
public class PagerIndicatorTabs : Grid
10-
{
11-
int _selectedIndex;
12-
13-
public Color DotColor { get; set; }
14-
public double DotSize { get; set; }
15-
16-
public PagerIndicatorTabs()
17-
{
18-
HorizontalOptions = LayoutOptions.CenterAndExpand;
19-
VerticalOptions = LayoutOptions.Center;
20-
DotColor = Color.Black;
21-
Device.OnPlatform(iOS: () => BackgroundColor = Color.Gray);
22-
23-
var assembly = typeof(PagerIndicatorTabs).GetTypeInfo().Assembly;
24-
foreach (var res in assembly.GetManifestResourceNames())
25-
System.Diagnostics.Debug.WriteLine("found resource: " + res);
26-
}
27-
28-
void CreateTabs()
29-
{
30-
31-
if(Children != null && Children.Count > 0) Children.Clear();
32-
33-
foreach(var item in ItemsSource)
34-
{
35-
36-
var index = Children.Count;
37-
var tab = new StackLayout {
38-
Orientation = StackOrientation.Vertical,
39-
HorizontalOptions = LayoutOptions.Center,
40-
VerticalOptions = LayoutOptions.Center,
41-
Padding = new Thickness(7),
42-
};
43-
Device.OnPlatform(
44-
iOS: () =>
45-
{
46-
tab.Children.Add(new Image { Source = "pin.png", HeightRequest = 20 });
47-
tab.Children.Add(new Label { Text = "Tab " + (index + 1), FontSize = 11 });
48-
},
49-
Android: () =>
50-
{
51-
tab.Children.Add(new Image { Source = "pin.png", HeightRequest = 25 });
52-
}
53-
);
54-
var tgr = new TapGestureRecognizer();
55-
tgr.Command = new Command(() =>
56-
{
57-
SelectedItem = ItemsSource[index];
58-
});
59-
tab.GestureRecognizers.Add(tgr);
60-
Children.Add(tab, index, 0);
61-
}
62-
}
63-
64-
public static BindableProperty ItemsSourceProperty =
65-
BindableProperty.Create(
66-
nameof(ItemsSource),
67-
typeof(IList),
68-
typeof(PagerIndicatorTabs),
69-
null,
70-
BindingMode.OneWay,
71-
propertyChanging: (bindable, oldValue, newValue) =>
72-
{
73-
((PagerIndicatorTabs)bindable).ItemsSourceChanging();
74-
},
75-
propertyChanged: (bindable, oldValue, newValue) =>
76-
{
77-
((PagerIndicatorTabs)bindable).ItemsSourceChanged();
78-
}
79-
);
80-
81-
public IList ItemsSource {
82-
get {
83-
return (IList)GetValue(ItemsSourceProperty);
84-
}
85-
set {
86-
SetValue (ItemsSourceProperty, value);
87-
}
88-
}
89-
90-
public static BindableProperty SelectedItemProperty =
91-
BindableProperty.Create(
92-
nameof(SelectedItem),
93-
typeof(object),
94-
typeof(PagerIndicatorTabs),
95-
null,
96-
BindingMode.TwoWay,
97-
propertyChanged: (bindable, oldValue, newValue) =>
98-
{
99-
((PagerIndicatorTabs)bindable).SelectedItemChanged();
100-
}
101-
);
102-
103-
public object SelectedItem {
104-
get {
105-
return GetValue (SelectedItemProperty);
106-
}
107-
set {
108-
SetValue (SelectedItemProperty, value);
109-
}
110-
}
111-
112-
void ItemsSourceChanging ()
113-
{
114-
if (ItemsSource != null)
115-
_selectedIndex = ItemsSource.IndexOf (SelectedItem);
116-
}
117-
118-
void ItemsSourceChanged ()
119-
{
120-
if (ItemsSource == null) return;
121-
122-
this.ColumnDefinitions.Clear();
123-
foreach(var item in ItemsSource)
124-
{
125-
this.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
126-
}
127-
128-
CreateTabs();
129-
}
130-
131-
void SelectedItemChanged () {
132-
133-
var selectedIndex = ItemsSource.IndexOf (SelectedItem);
134-
var pagerIndicators = Children.Cast<StackLayout> ().ToList ();
135-
136-
foreach(var pi in pagerIndicators)
137-
{
138-
UnselectTab(pi);
139-
}
140-
141-
if(selectedIndex > -1)
142-
{
143-
SelectTab(pagerIndicators[selectedIndex]);
144-
}
145-
}
146-
147-
static void UnselectTab (StackLayout tab)
148-
{
149-
tab.Opacity = 0.5;
150-
}
151-
152-
static void SelectTab (StackLayout tab)
153-
{
154-
tab.Opacity = 1.0;
155-
}
156-
}
9+
public class PagerIndicatorTabs : Grid
10+
{
11+
int _selectedIndex;
12+
13+
public Color DotColor { get; set; }
14+
public double DotSize { get; set; }
15+
16+
public PagerIndicatorTabs()
17+
{
18+
HorizontalOptions = LayoutOptions.CenterAndExpand;
19+
VerticalOptions = LayoutOptions.Center;
20+
DotColor = Color.Black;
21+
switch (Device.RuntimePlatform)
22+
{
23+
case Device.iOS:
24+
BackgroundColor = Color.Gray;
25+
break;
26+
}
27+
28+
var assembly = typeof(PagerIndicatorTabs).GetTypeInfo().Assembly;
29+
foreach (var res in assembly.GetManifestResourceNames())
30+
System.Diagnostics.Debug.WriteLine("found resource: " + res);
31+
}
32+
33+
void CreateTabs()
34+
{
35+
36+
if (Children != null && Children.Count > 0) Children.Clear();
37+
38+
foreach (var item in ItemsSource)
39+
{
40+
41+
var index = Children.Count;
42+
var tab = new StackLayout
43+
{
44+
Orientation = StackOrientation.Vertical,
45+
HorizontalOptions = LayoutOptions.Center,
46+
VerticalOptions = LayoutOptions.Center,
47+
Padding = new Thickness(7),
48+
};
49+
switch (Device.RuntimePlatform)
50+
{
51+
case Device.iOS:
52+
tab.Children.Add(new Image { Source = "pin.png", HeightRequest = 20 });
53+
tab.Children.Add(new Label { Text = "Tab " + (index + 1), FontSize = 11 });
54+
break;
55+
56+
case Device.Android:
57+
tab.Children.Add(new Image { Source = "pin.png", HeightRequest = 25 });
58+
break;
59+
}
60+
61+
var tgr = new TapGestureRecognizer();
62+
tgr.Command = new Command(() =>
63+
{
64+
SelectedItem = ItemsSource[index];
65+
});
66+
tab.GestureRecognizers.Add(tgr);
67+
Children.Add(tab, index, 0);
68+
}
69+
}
70+
71+
public static BindableProperty ItemsSourceProperty =
72+
BindableProperty.Create(
73+
nameof(ItemsSource),
74+
typeof(IList),
75+
typeof(PagerIndicatorTabs),
76+
null,
77+
BindingMode.OneWay,
78+
propertyChanging: (bindable, oldValue, newValue) =>
79+
{
80+
((PagerIndicatorTabs)bindable).ItemsSourceChanging();
81+
},
82+
propertyChanged: (bindable, oldValue, newValue) =>
83+
{
84+
((PagerIndicatorTabs)bindable).ItemsSourceChanged();
85+
}
86+
);
87+
88+
public IList ItemsSource
89+
{
90+
get
91+
{
92+
return (IList)GetValue(ItemsSourceProperty);
93+
}
94+
set
95+
{
96+
SetValue(ItemsSourceProperty, value);
97+
}
98+
}
99+
100+
public static BindableProperty SelectedItemProperty =
101+
BindableProperty.Create(
102+
nameof(SelectedItem),
103+
typeof(object),
104+
typeof(PagerIndicatorTabs),
105+
null,
106+
BindingMode.TwoWay,
107+
propertyChanged: (bindable, oldValue, newValue) =>
108+
{
109+
((PagerIndicatorTabs)bindable).SelectedItemChanged();
110+
}
111+
);
112+
113+
public object SelectedItem
114+
{
115+
get
116+
{
117+
return GetValue(SelectedItemProperty);
118+
}
119+
set
120+
{
121+
SetValue(SelectedItemProperty, value);
122+
}
123+
}
124+
125+
void ItemsSourceChanging()
126+
{
127+
if (ItemsSource != null)
128+
_selectedIndex = ItemsSource.IndexOf(SelectedItem);
129+
}
130+
131+
void ItemsSourceChanged()
132+
{
133+
if (ItemsSource == null) return;
134+
135+
this.ColumnDefinitions.Clear();
136+
foreach (var item in ItemsSource)
137+
{
138+
this.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
139+
}
140+
141+
CreateTabs();
142+
}
143+
144+
void SelectedItemChanged()
145+
{
146+
147+
var selectedIndex = ItemsSource.IndexOf(SelectedItem);
148+
var pagerIndicators = Children.Cast<StackLayout>().ToList();
149+
150+
foreach (var pi in pagerIndicators)
151+
{
152+
UnselectTab(pi);
153+
}
154+
155+
if (selectedIndex > -1)
156+
{
157+
SelectTab(pagerIndicators[selectedIndex]);
158+
}
159+
}
160+
161+
static void UnselectTab(StackLayout tab)
162+
{
163+
tab.Opacity = 0.5;
164+
}
165+
166+
static void SelectTab(StackLayout tab)
167+
{
168+
tab.Opacity = 1.0;
169+
}
170+
}
157171
}
158172

src/Droid/CustomLayouts.Droid.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<AndroidApplication>True</AndroidApplication>
1616
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
1717
<AssemblyName>CustomLayouts.Droid</AssemblyName>
18-
<TargetFrameworkVersion>v6.0.99</TargetFrameworkVersion>
18+
<TargetFrameworkVersion>v7.1</TargetFrameworkVersion>
1919
</PropertyGroup>
2020
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2121
<DebugSymbols>true</DebugSymbols>
@@ -67,19 +67,19 @@
6767
<HintPath>..\packages\Xamarin.Android.Support.v7.MediaRouter.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.MediaRouter.dll</HintPath>
6868
</Reference>
6969
<Reference Include="FormsViewGroup">
70-
<HintPath>..\packages\Xamarin.Forms.2.2.0.31\lib\MonoAndroid10\FormsViewGroup.dll</HintPath>
70+
<HintPath>..\packages\Xamarin.Forms.2.3.4.231\lib\MonoAndroid10\FormsViewGroup.dll</HintPath>
7171
</Reference>
7272
<Reference Include="Xamarin.Forms.Core">
73-
<HintPath>..\packages\Xamarin.Forms.2.2.0.31\lib\MonoAndroid10\Xamarin.Forms.Core.dll</HintPath>
73+
<HintPath>..\packages\Xamarin.Forms.2.3.4.231\lib\MonoAndroid10\Xamarin.Forms.Core.dll</HintPath>
7474
</Reference>
7575
<Reference Include="Xamarin.Forms.Platform.Android">
76-
<HintPath>..\packages\Xamarin.Forms.2.2.0.31\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll</HintPath>
76+
<HintPath>..\packages\Xamarin.Forms.2.3.4.231\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll</HintPath>
7777
</Reference>
7878
<Reference Include="Xamarin.Forms.Platform">
79-
<HintPath>..\packages\Xamarin.Forms.2.2.0.31\lib\MonoAndroid10\Xamarin.Forms.Platform.dll</HintPath>
79+
<HintPath>..\packages\Xamarin.Forms.2.3.4.231\lib\MonoAndroid10\Xamarin.Forms.Platform.dll</HintPath>
8080
</Reference>
8181
<Reference Include="Xamarin.Forms.Xaml">
82-
<HintPath>..\packages\Xamarin.Forms.2.2.0.31\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll</HintPath>
82+
<HintPath>..\packages\Xamarin.Forms.2.3.4.231\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll</HintPath>
8383
</Reference>
8484
</ItemGroup>
8585
<ItemGroup>
@@ -109,5 +109,5 @@
109109
<Import Project="..\CustomLayouts\CustomLayouts.projitems" Label="Shared" Condition="Exists('..\CustomLayouts\CustomLayouts.projitems')" />
110110
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
111111
<Import Project="..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" />
112-
<Import Project="..\packages\Xamarin.Forms.2.2.0.31\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.2.2.0.31\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
112+
<Import Project="..\packages\Xamarin.Forms.2.3.4.231\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.2.3.4.231\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" />
113113
</Project>
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.chrisriesgo.xamarin-forms-carouselview">
3-
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="21" />
4-
<application android:label="CarouselView Demo">
5-
</application>
3+
<uses-sdk android:minSdkVersion="15" />
4+
<application android:label="CarouselView Demo"></application>
65
</manifest>

0 commit comments

Comments
 (0)