Skip to content

Commit 12cc554

Browse files
committed
Merge branch 'main' into shadow
2 parents 139350c + 02efc91 commit 12cc554

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+639
-220
lines changed

eng/AndroidX.targets

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,56 @@
11
<Project>
2-
<PropertyGroup>
3-
<!-- Uncomment to use preview packages -->
4-
<!-- <_AndroidXVersion>-net6preview03.4680155</_AndroidXVersion> -->
5-
</PropertyGroup>
62
<ItemGroup>
73
<PackageReference
84
Update="Xamarin.AndroidX.AppCompat.AppCompatResources"
9-
Version="1.2.0.7$(_AndroidXVersion)"
5+
Version="1.3.1.1"
106
/>
117
<PackageReference
128
Update="Xamarin.AndroidX.Browser"
13-
Version="1.3.0.5$(_AndroidXVersion)"
9+
Version="1.3.0.6"
1410
/>
1511
<PackageReference
1612
Update="Xamarin.AndroidX.Legacy.Support.V4"
17-
Version="1.0.0.7$(_AndroidXVersion)"
13+
Version="1.0.0.8"
1814
/>
1915
<PackageReference
2016
Update="Xamarin.AndroidX.Lifecycle.LiveData"
21-
Version="2.3.1$(_AndroidXVersion)"
17+
Version="2.3.1.1"
2218
/>
2319
<PackageReference
2420
Update="Xamarin.AndroidX.Navigation.UI"
25-
Version="2.3.5$(_AndroidXVersion)"
21+
Version="2.3.5.1"
2622
/>
2723
<PackageReference
2824
Update="Xamarin.AndroidX.Navigation.Fragment"
29-
Version="2.3.5$(_AndroidXVersion)"
25+
Version="2.3.5.1"
3026
/>
3127
<PackageReference
3228
Update="Xamarin.AndroidX.Navigation.Runtime"
33-
Version="2.3.5$(_AndroidXVersion)"
29+
Version="2.3.5.1"
3430
/>
3531
<PackageReference
3632
Update="Xamarin.AndroidX.Navigation.Common"
37-
Version="2.3.5$(_AndroidXVersion)"
33+
Version="2.3.5.1"
3834
/>
3935
<PackageReference
4036
Update="Xamarin.AndroidX.MediaRouter"
41-
Version="1.2.2.1$(_AndroidXVersion)"
37+
Version="1.2.4.1"
4238
/>
4339
<PackageReference
4440
Update="Xamarin.AndroidX.Palette"
45-
Version="1.0.0.7$(_AndroidXVersion)"
41+
Version="1.0.0.8"
4642
/>
4743
<PackageReference
4844
Update="Xamarin.AndroidX.RecyclerView"
49-
Version="1.2.0$(_AndroidXVersion)"
45+
Version="1.2.1.1"
5046
/>
5147
<PackageReference
5248
Update="Xamarin.Build.Download"
5349
Version="0.10.0"
5450
/>
5551
<PackageReference
5652
Update="Xamarin.Google.Android.Material"
57-
Version="1.3.0.1$(_AndroidXVersion)"
53+
Version="1.4.0.1"
5854
/>
5955
<PackageReference
6056
Update="Xamarin.AndroidX.Migration"

src/Compatibility/Core/src/Android/AppCompat/TabbedPageRenderer.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using AndroidX.ViewPager.Widget;
1313
using Google.Android.Material.BottomNavigation;
1414
using Google.Android.Material.BottomSheet;
15+
using Google.Android.Material.Navigation;
1516
using Google.Android.Material.Tabs;
1617
using Microsoft.Maui.Controls.Internals;
1718
using Microsoft.Maui.Controls.Platform;
@@ -29,7 +30,7 @@ public class TabbedPageRenderer : VisualElementRenderer<TabbedPage>,
2930
#pragma warning disable CS0618 // Type or member is obsolete
3031
TabLayout.IOnTabSelectedListener,
3132
#pragma warning restore CS0618 // Type or member is obsolete
32-
ViewPager.IOnPageChangeListener, IManageFragments, BottomNavigationView.IOnNavigationItemSelectedListener
33+
ViewPager.IOnPageChangeListener, IManageFragments, NavigationBarView.IOnItemSelectedListener
3334
{
3435
Drawable _backgroundDrawable;
3536
Drawable _wrappedBackgroundDrawable;
@@ -193,7 +194,7 @@ protected override void Dispose(bool disposing)
193194

194195
if (_bottomNavigationView != null)
195196
{
196-
_bottomNavigationView.SetOnNavigationItemSelectedListener(null);
197+
_bottomNavigationView.SetOnItemSelectedListener(null);
197198
_bottomNavigationView.Dispose();
198199
_bottomNavigationView = null;
199200
}
@@ -262,7 +263,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
262263
if (_bottomNavigationView != null)
263264
{
264265
_relativeLayout.RemoveView(_bottomNavigationView);
265-
_bottomNavigationView.SetOnNavigationItemSelectedListener(null);
266+
_bottomNavigationView.SetOnItemSelectedListener(null);
266267
}
267268

268269
var bottomNavigationViewLayoutParams = new AWidget.RelativeLayout.LayoutParams(
@@ -462,7 +463,7 @@ void OnChildrenCollectionChanged(object sender, NotifyCollectionChangedEventArgs
462463
else
463464
{
464465
SetupBottomNavigationView(e);
465-
bottomNavigationView.SetOnNavigationItemSelectedListener(this);
466+
bottomNavigationView.SetOnItemSelectedListener(this);
466467
}
467468

468469
UpdateIgnoreContainerAreas();

src/Compatibility/Core/src/Android/CollectionView/SelectableItemsViewAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ internal void MarkNativeSelection(object selectedItem)
6767

6868
for (int i = 0; i < _currentViewHolders.Count; i++)
6969
{
70-
if (_currentViewHolders[i].AdapterPosition == position)
70+
if (_currentViewHolders[i].BindingAdapterPosition == position)
7171
{
7272
_currentViewHolders[i].IsSelected = true;
7373
return;

src/Compatibility/Core/src/Android/CollectionView/SelectableViewHolder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void OnClick(global::Android.Views.View view)
4141
{
4242
if (_isSelectionEnabled)
4343
{
44-
OnViewHolderClicked(AdapterPosition);
44+
OnViewHolderClicked(BindingAdapterPosition);
4545
}
4646
}
4747

src/Compatibility/Core/src/Android/Renderers/ShellItemRenderer.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Android.Widget;
1010
using Google.Android.Material.BottomNavigation;
1111
using Google.Android.Material.BottomSheet;
12+
using Google.Android.Material.Navigation;
1213
using Microsoft.Maui.Controls.Platform;
1314
using Microsoft.Maui.Graphics;
1415
using AColor = Android.Graphics.Color;
@@ -19,16 +20,16 @@
1920

2021
namespace Microsoft.Maui.Controls.Compatibility.Platform.Android
2122
{
22-
public class ShellItemRenderer : ShellItemRendererBase, BottomNavigationView.IOnNavigationItemSelectedListener, IAppearanceObserver
23+
public class ShellItemRenderer : ShellItemRendererBase, NavigationBarView.IOnItemSelectedListener, IAppearanceObserver
2324
{
24-
#region IOnNavigationItemSelectedListener
25+
#region IOnItemSelectedListener
2526

26-
bool BottomNavigationView.IOnNavigationItemSelectedListener.OnNavigationItemSelected(IMenuItem item)
27+
bool NavigationBarView.IOnItemSelectedListener.OnNavigationItemSelected(IMenuItem item)
2728
{
2829
return OnItemSelected(item);
2930
}
3031

31-
#endregion IOnNavigationItemSelectedListener
32+
#endregion IOnItemSelectedListener
3233

3334
#region IAppearanceObserver
3435

@@ -65,7 +66,7 @@ public override AView OnCreateView(LayoutInflater inflater, ViewGroup container,
6566
_navigationArea = _outerLayout.FindViewById<FrameLayout>(Resource.Id.bottomtab_navarea);
6667

6768
_bottomView.SetBackgroundColor(Colors.White.ToAndroid());
68-
_bottomView.SetOnNavigationItemSelectedListener(this);
69+
_bottomView.SetOnItemSelectedListener(this);
6970

7071
if (ShellItem == null)
7172
throw new InvalidOperationException("Active Shell Item not set. Have you added any Shell Items to your Shell?");
@@ -104,7 +105,7 @@ void Destroy()
104105

105106
if (_bottomView != null)
106107
{
107-
_bottomView?.SetOnNavigationItemSelectedListener(null);
108+
_bottomView?.SetOnItemSelectedListener(null);
108109
_bottomView?.Background?.Dispose();
109110
_bottomView?.Dispose();
110111
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
using Microsoft.Maui;
2+
using Microsoft.Maui.Controls;
3+
using Microsoft.Maui.Graphics;
4+
using Shapes = Microsoft.Maui.Controls.Shapes;
5+
6+
namespace Maui.Controls.Sample.Pages
7+
{
8+
public class LayoutUpdatesPage : Base.BasePage
9+
{
10+
public LayoutUpdatesPage()
11+
{
12+
var root = new GridLayout() { Margin = 40, BackgroundColor = Colors.Beige };
13+
14+
root.RowDefinitions = new RowDefinitionCollection()
15+
{
16+
new RowDefinition(){ Height = GridLength.Auto },
17+
new RowDefinition(){ Height = GridLength.Auto },
18+
new RowDefinition(){ Height = GridLength.Auto },
19+
new RowDefinition(){ Height = GridLength.Auto }
20+
};
21+
22+
root.ColumnDefinitions = new ColumnDefinitionCollection()
23+
{
24+
new ColumnDefinition(){ Width = GridLength.Star },
25+
new ColumnDefinition(){ Width = GridLength.Star },
26+
};
27+
28+
var addButton = new Button { Text = "Add" };
29+
root.Add(addButton);
30+
31+
var removeButton = new Button { Text = "Remove" };
32+
root.Add(removeButton);
33+
root.SetColumn(removeButton, 1);
34+
35+
var insertButton = new Button { Text = "Insert" };
36+
root.Add(insertButton);
37+
root.SetRow(insertButton, 1);
38+
39+
var clearButton = new Button { Text = "Clear" };
40+
root.Add(clearButton);
41+
root.SetColumn(clearButton, 1);
42+
root.SetRow(clearButton, 1);
43+
44+
var updateButton = new Button { Text = "Update" };
45+
root.Add(updateButton);
46+
root.SetRow(updateButton, 2);
47+
48+
var stack = new VerticalStackLayout();
49+
50+
double shapeWidth = 200;
51+
double shapeHeight = 80;
52+
double overlap = -20;
53+
double leftMarginIncrement = 20;
54+
55+
var r1 = new Shapes.Rectangle() { WidthRequest = shapeWidth, HeightRequest = shapeHeight, Fill = new SolidColorBrush(NextColor()), Margin = new Thickness(0, 0, 0, 0) };
56+
var r2 = new Shapes.Rectangle() { WidthRequest = shapeWidth, HeightRequest = shapeHeight, Fill = new SolidColorBrush(NextColor()), Margin = new Thickness(leftMarginIncrement, overlap, 0, 0) };
57+
58+
stack.Add(r1);
59+
stack.Add(r2);
60+
61+
root.Add(stack);
62+
root.SetRow(stack, 3);
63+
root.SetColumnSpan(stack, 2);
64+
65+
addButton.Clicked += (sender, args) => {
66+
var left = leftMarginIncrement * stack.Count;
67+
var rect = new Shapes.Rectangle() { WidthRequest = shapeWidth, HeightRequest = shapeHeight, Fill = new SolidColorBrush(NextColor()), Margin = new Thickness(left, overlap, 0, 0) };
68+
stack.Add(rect);
69+
};
70+
71+
insertButton.Clicked += (sender, args) => {
72+
73+
if (stack.Count < 2)
74+
{
75+
return;
76+
}
77+
78+
var left = leftMarginIncrement * stack.Count;
79+
80+
var rect = new Shapes.Rectangle() { WidthRequest = shapeWidth, HeightRequest = shapeHeight, Fill = new SolidColorBrush(NextColor()), Margin = new Thickness(left, overlap, 0, 0) };
81+
stack.Insert(1, rect);
82+
};
83+
84+
clearButton.Clicked += (sender, args) => {
85+
stack.Clear();
86+
};
87+
88+
removeButton.Clicked += (sender, args) => {
89+
if (stack.Count > 0)
90+
{
91+
stack.RemoveAt(stack.Count - 1);
92+
}
93+
};
94+
95+
updateButton.Clicked += (sender, args) => {
96+
if (stack.Count > 0)
97+
{
98+
var left = leftMarginIncrement * stack.Count;
99+
var rect = new Shapes.Rectangle() { WidthRequest = shapeWidth, HeightRequest = shapeHeight, Fill = new SolidColorBrush(NextColor()), Margin = new Thickness(left, overlap, 0, 0) };
100+
stack[0] = rect;
101+
}
102+
};
103+
104+
Content = root;
105+
}
106+
107+
int _colorIndex;
108+
109+
Color[] _colors = new Color[]
110+
{
111+
Colors.Red, Colors.Blue, Colors.Green, Colors.Yellow, Colors.Orange, Colors.Purple
112+
};
113+
114+
Color NextColor()
115+
{
116+
var color = _colors[_colorIndex];
117+
118+
_colorIndex += 1;
119+
if (_colorIndex >= _colors.Length)
120+
{
121+
_colorIndex = 0;
122+
}
123+
124+
return color;
125+
}
126+
}
127+
}

src/Controls/samples/Controls.Sample/ViewModels/LayoutsViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ protected override IEnumerable<SectionModel> CreateItems() => new[]
3838

3939
new SectionModel(typeof(VerticalStackLayoutPage), "VerticalStackLayout",
4040
"A VerticalStackLayout organizes child views in a one-dimensional vertical stack."),
41+
42+
new SectionModel(typeof(LayoutUpdatesPage), "Layout Updates",
43+
"Demonstrations of updating layouts"),
4144
};
4245
}
4346
}

src/Controls/src/Core/Application.cs

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,56 +63,33 @@ public IAppLinks AppLinks
6363

6464
public static Application Current { get; set; }
6565

66+
Page _pendingMainPage;
67+
6668
public Page MainPage
6769
{
6870
get
6971
{
7072
if (Windows.Count == 0)
71-
return null;
73+
return _pendingMainPage;
7274

7375
return Windows[0].Page;
7476
}
7577
set
7678
{
77-
if (value == null)
78-
throw new ArgumentNullException(nameof(value));
79-
8079
if (MainPage == value)
8180
return;
8281

8382
OnPropertyChanging();
8483

85-
var previousPage = MainPage;
86-
87-
if (previousPage != null)
88-
previousPage.Parent = null;
89-
9084
if (Windows.Count == 0)
9185
{
92-
// there are no windows, so add a new window
93-
94-
AddWindow(new Window(value));
86+
_pendingMainPage = value;
9587
}
9688
else
9789
{
98-
// find the best window and replace the page
99-
100-
var theWindow = Windows[0];
101-
foreach (var window in Windows)
102-
{
103-
if (window.Page == previousPage)
104-
{
105-
theWindow = window;
106-
break;
107-
}
108-
}
109-
110-
theWindow.Page = value;
90+
Windows[0].Page = value;
11191
}
11292

113-
if (previousPage != null)
114-
previousPage.NavigationProxy.Inner = NavigationProxy;
115-
11693
OnPropertyChanged();
11794
}
11895
}

0 commit comments

Comments
 (0)