diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/AppDelegate.cs b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/AppDelegate.cs deleted file mode 100644 index 6b67e0310693..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/AppDelegate.cs +++ /dev/null @@ -1,319 +0,0 @@ -using System; -using System.Globalization; -using System.Linq; -using AppKit; -using CoreGraphics; -using Foundation; -using Xamarin.Forms.Controls; -using Xamarin.Forms.Controls.Issues; -using Xamarin.Forms.Platform.MacOS; - -namespace Xamarin.Forms.ControlGallery.MacOS -{ - [Register("AppDelegate")] - public class AppDelegate : FormsApplicationDelegate - { - - NSWindow _window; - public AppDelegate() - { - ObjCRuntime.Runtime.MarshalManagedException += (sender, args) => - { - Console.WriteLine(args.Exception); - }; - - var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled; - - var rect = new CoreGraphics.CGRect(200, 1000, 1024, 768); - //var rect = NSWindow.FrameRectFor(NSScreen.MainScreen.Frame, style); - _window = new NSWindow(rect, style, NSBackingStore.Buffered, false); - _window.Title = "Twitter XF Mac"; - _window.TitleVisibility = NSWindowTitleVisibility.Hidden; - } - - public override NSWindow MainWindow - { - get { return _window; } - } - - - public override void DidFinishLaunching(NSNotification notification) - { - Forms.Init(); - FormsMaps.Init(); - - var app = new App(); - SetupMenu(app); - - // When the native control gallery loads up, it'll let us know so we can add the nested native controls - MessagingCenter.Subscribe(this, NestedNativeControlGalleryPage.ReadyForNativeControlsMessage, AddNativeControls); - MessagingCenter.Subscribe(this, Bugzilla40911.ReadyToSetUp40911Test, SetUp40911Test); - - // When the native binding gallery loads up, it'll let us know so we can set up the native bindings - MessagingCenter.Subscribe(this, NativeBindingGalleryPage.ReadyForNativeBindingsMessage, AddNativeBindings); - - LoadApplication(app); - base.DidFinishLaunching(notification); - } - - void SetupMenu(Application app) - { - NativeMenuItemCreator = (menuItem) => - { - if (menuItem is SeparatorMenuItem) - { - return NSMenuItem.SeparatorItem; - } - - var nsMenuItem = new NSMenuItem { Title = menuItem.Text }; - if (menuItem.Text == "Small icons") - { - nsMenuItem.State = NSCellStateValue.On; - nsMenuItem.Activated += CheckableNsMenuItem_Activated; - } - - return nsMenuItem; - }; - - var menu = new Menu(); - - var appMenu = new Menu(); - - appMenu.Items.Add(new MenuItem { Text = "App menu test" }); - menu.Add(appMenu); - - var fileMenu = new Menu { Text = "File" }; - fileMenu.Items.Add(new MenuItem { Text = "New" }); - fileMenu.Items.Add(new MenuItem { Text = "Open" }); - menu.Add(fileMenu); - - var viewMenu = new Menu { Text = "View" }; - var smallIconsMenuItem = new MenuItem { Text = "Small icons" }; - smallIconsMenuItem.Clicked += CheckableMenuItem_Clicked; - viewMenu.Items.Add(smallIconsMenuItem); - viewMenu.Items.Add(new MenuItem { Text = "Large icons" }); - viewMenu.Items.Add(new SeparatorMenuItem()); - viewMenu.Items.Add(new MenuItem { Text = "List", IsEnabled = false }); - viewMenu.Items.Add(new MenuItem { Text = "Details" }); - menu.Add(viewMenu); - - Element.SetMenu(app, menu); - - void CheckableNsMenuItem_Activated(object sender, EventArgs e) - { - // switch state for checkable menu item - var nsMenuItem = sender as NSMenuItem; - nsMenuItem.State = nsMenuItem.State == NSCellStateValue.On ? NSCellStateValue.Off : NSCellStateValue.On; - } - - void CheckableMenuItem_Clicked(object sender, EventArgs e) - { - var menuItem = sender as MenuItem; - var alert = new NSAlert { MessageText = $"{menuItem.Text} has been clicked!" }; - alert.RunModal(); - } - } - - protected override void SetupMainAppMenu(NSMenu nativeMenu) - { - base.SetupMainAppMenu(nativeMenu); - - // reorder menu items - it can be needed if we add submenus as they are added after simple items - var appMenu = nativeMenu.ItemAt(0); - var testMenuItem = appMenu.Submenu.Items.Last(); - appMenu.Submenu.RemoveItem(testMenuItem); - appMenu.Submenu.InsertItem(testMenuItem, 0); - } - - void AddNativeControls(NestedNativeControlGalleryPage page) - { - if (page.NativeControlsAdded) - { - return; - } - - StackLayout sl = page.Layout; - - // Create and add a native UILabel - var originalText = "I am a native UILabel"; - var longerText = - "I am a native UILabel with considerably more text. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."; - - var uilabel = new NSTextField - { - StringValue = originalText, - MaximumNumberOfLines = 0, - LineBreakMode = NSLineBreakMode.ByWordWrapping, - Font = NSFont.FromFontName("Helvetica", 24f) - }; - - sl?.Children.Add(uilabel); - - // Create and add a native Button - var uibutton = NSButtonExtensions.CreateButton("Toggle Text Amount", () => - { - uilabel.StringValue = uilabel.StringValue == originalText ? longerText : originalText; - uilabel.SizeToFit(); - }); - uibutton.Font = NSFont.FromFontName("Helvetica", 14f); - - - sl?.Children.Add(uibutton.ToView()); - - // Create some control which we know don't behave correctly with regard to measurement - var difficultControl0 = new BrokenNativeControl - { - Font = NSFont.FromFontName("Helvetica", 14f), - MaximumNumberOfLines = 0, - LineBreakMode = NSLineBreakMode.ByWordWrapping, - StringValue = "Doesn't play nice with sizing. That's why there's a big gap around it." - }; - - var difficultControl1 = new BrokenNativeControl - { - Font = NSFont.FromFontName("Helvetica", 14f), - MaximumNumberOfLines = 0, - LineBreakMode = NSLineBreakMode.ByWordWrapping, - StringValue = "Custom size fix specified. No gaps." - }; - - var explanation0 = new NSTextField - { - StringValue = "The next control is a customized label with a bad SizeThatFits implementation.", - MaximumNumberOfLines = 0, - LineBreakMode = NSLineBreakMode.ByWordWrapping, - Font = NSFont.FromFontName("Helvetica", 14f), - }; - - var explanation1 = new NSTextField - { - StringValue = "The next control is the same broken class as above, but we pass in an override to the GetDesiredSize method.", - MaximumNumberOfLines = 0, - LineBreakMode = NSLineBreakMode.ByWordWrapping, - Font = NSFont.FromFontName("Helvetica", 14f), - }; - - // Add a misbehaving control - sl?.Children.Add(explanation0); - sl?.Children.Add(difficultControl0); - - // Add the misbehaving control with a custom delegate for FixSize - sl?.Children.Add(explanation1); - sl?.Children.Add(difficultControl1, FixSize); - - page.NativeControlsAdded = true; - } - - SizeRequest? FixSize(NativeViewWrapperRenderer renderer, double width, double height) - { - var uiView = renderer.Control; - var view = renderer.Element; - - if (uiView == null || view == null) - { - return null; - } - - var constraint = new CGSize(width, height); - - // Let the BrokenNativeControl determine its size (which we know will be wrong) - var badRect = uiView.FittingSize; - - // And we'll use the width (which is fine) and substitute our own height - return new SizeRequest(new Size(badRect.Width, 20)); - } - - void AddNativeBindings(NativeBindingGalleryPage page) - { - if (page.NativeControlsAdded) - return; - - StackLayout sl = page.Layout; - - int width = 200; - int heightCustomLabelView = 100; - - var uilabel = new NSTextField(new CGRect(0, 0, width, heightCustomLabelView)) - { - BackgroundColor = NSColor.Clear, - Editable = false, - Bezeled = false, - DrawsBackground = false, - MaximumNumberOfLines = 0, - LineBreakMode = NSLineBreakMode.ByWordWrapping, - Font = NSFont.FromFontName("Helvetica", 24f), - StringValue = "DefaultText" - }; - - var uibuttonColor = NSButtonExtensions.CreateButton("Toggle Text Color Binding", () => uilabel.TextColor = NSColor.Blue); - uibuttonColor.Font = NSFont.FromFontName("Helvetica", 14f); - - uilabel.SetBinding("StringValue", new Binding("NativeLabel")); - uilabel.SetBinding(nameof(uilabel.TextColor), new Binding("NativeLabelColor", converter: new ColorConverter())); - - sl?.Children.Add(uilabel); - sl?.Children.Add(uibuttonColor.ToView()); - //var colorPicker = new NSColorWell(); - //colorPicker.SetBinding("SelectedColor", new Binding("NativeLabelColor", BindingMode.TwoWay, new ColorConverter()), "ColorPicked"); - //sl?.Children.Add(colorPicker); - page.NativeControlsAdded = true; - } - - #region Stuff for repro of Bugzilla case 40911 - - void SetUp40911Test(Bugzilla40911 page) - { - var button = new Button { Text = "Start" }; - - button.Clicked += (s, e) => - { - StartPressed40911(); - }; - - page._40911Layout.Children.Add(button); - } - - public void StartPressed40911() - { - var loginViewController = new NSViewController { View = { } }; - var button = NSButtonExtensions.CreateButton("Login", () => - { - Xamarin.Forms.Application.Current.MainPage = new ContentPage { Content = new Label { Text = "40911 Success" } }; - //loginViewController.DismissViewController()true, null); - - }); - - button.Frame = new CGRect(20, 100, 200, 44); - loginViewController.View.AddSubview(button); - - var window = NSApplication.SharedApplication.KeyWindow; - var vc = window.ContentViewController; - while (vc.PresentedViewControllers.Length > 0) - { - vc = vc.PresentedViewControllers[0]; - } - - //vc.PresentViewController(loginViewController, new NSViewControllerPresentationAnimator(); - } - - #endregion - - public class ColorConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value is Color) - return ((Color)value).ToNSColor(); - return value; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value is NSColor) - return ((NSColor)value).ToColor(); - return value; - } - } - } -} - diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-128.png b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-128.png deleted file mode 100644 index d0b5a8098ec9..000000000000 Binary files a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-128.png and /dev/null differ diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-128@2x.png b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-128@2x.png deleted file mode 100644 index f4c8d29047b8..000000000000 Binary files a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-128@2x.png and /dev/null differ diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-16.png b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-16.png deleted file mode 100644 index ebb5a0fe4e7e..000000000000 Binary files a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-16.png and /dev/null differ diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-16@2x.png b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-16@2x.png deleted file mode 100644 index 0986d31bebb1..000000000000 Binary files a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-16@2x.png and /dev/null differ diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-256.png b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-256.png deleted file mode 100644 index f4c8d29047b8..000000000000 Binary files a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-256.png and /dev/null differ diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-256@2x.png b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-256@2x.png deleted file mode 100644 index a142c83fb1c3..000000000000 Binary files a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-256@2x.png and /dev/null differ diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-32.png b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-32.png deleted file mode 100644 index 0986d31bebb1..000000000000 Binary files a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-32.png and /dev/null differ diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-32@2x.png b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-32@2x.png deleted file mode 100644 index 412d6ca9b42c..000000000000 Binary files a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-32@2x.png and /dev/null differ diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-512.png b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-512.png deleted file mode 100644 index a142c83fb1c3..000000000000 Binary files a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-512.png and /dev/null differ diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-512@2x.png b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-512@2x.png deleted file mode 100644 index e99022ae84d0..000000000000 Binary files a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/AppIcon-512@2x.png and /dev/null differ diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/Contents.json b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/Contents.json deleted file mode 100644 index 6b28545295b1..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/AppIcons.appiconset/Contents.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "images": [ - { - "filename": "AppIcon-16.png", - "size": "16x16", - "scale": "1x", - "idiom": "mac" - }, - { - "filename": "AppIcon-16@2x.png", - "size": "16x16", - "scale": "2x", - "idiom": "mac" - }, - { - "filename": "AppIcon-32.png", - "size": "32x32", - "scale": "1x", - "idiom": "mac" - }, - { - "filename": "AppIcon-32@2x.png", - "size": "32x32", - "scale": "2x", - "idiom": "mac" - }, - { - "filename": "AppIcon-128.png", - "size": "128x128", - "scale": "1x", - "idiom": "mac" - }, - { - "filename": "AppIcon-128@2x.png", - "size": "128x128", - "scale": "2x", - "idiom": "mac" - }, - { - "filename": "AppIcon-256.png", - "size": "256x256", - "scale": "1x", - "idiom": "mac" - }, - { - "filename": "AppIcon-256@2x.png", - "size": "256x256", - "scale": "2x", - "idiom": "mac" - }, - { - "filename": "AppIcon-512.png", - "size": "512x512", - "scale": "1x", - "idiom": "mac" - }, - { - "filename": "AppIcon-512@2x.png", - "size": "512x512", - "scale": "2x", - "idiom": "mac" - } - ], - "info": { - "version": 1, - "author": "xcode" - } -} \ No newline at end of file diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/Contents.json b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/Contents.json deleted file mode 100644 index 4caf392f92c9..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/BrokenNativeControl.cs b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/BrokenNativeControl.cs deleted file mode 100644 index 5c35366492ac..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/BrokenNativeControl.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using AppKit; -using CoreGraphics; - -namespace Xamarin.Forms.ControlGallery.MacOS -{ - /// - /// This is a custom Android control which deliberately does some incorrect measuring/layout - /// - public class BrokenNativeControl : NSTextField - { - public override string StringValue - { - get { return base.StringValue; } - set { base.StringValue = value.ToUpper(); } - } - - public override CGSize SizeThatFits(CGSize size) - { - return new CGSize(size.Width, 150); - } - } -} diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/CustomRenderers.cs b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/CustomRenderers.cs deleted file mode 100644 index ae0588965e88..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/CustomRenderers.cs +++ /dev/null @@ -1,346 +0,0 @@ -using System; -using System.Collections.Generic; -using AppKit; -using CoreGraphics; -using Foundation; -using Xamarin.Forms; -using Xamarin.Forms.ControlGallery.MacOS; -using Xamarin.Forms.Controls.Issues; -using Xamarin.Forms.Platform.MacOS; - -[assembly: ExportRenderer(typeof(NativeCell), typeof(NativeMacCellRenderer))] -[assembly: ExportRenderer(typeof(NativeListView2), typeof(NativeMacOSListViewRenderer))] -[assembly: ExportRenderer(typeof(NativeListView), typeof(NativeListViewRenderer))] -namespace Xamarin.Forms.ControlGallery.MacOS -{ - public class NativeMacOSListViewRenderer : ViewRenderer - { - NSTableView _nsTableView; - public NativeMacOSListViewRenderer() - { - } - - protected override void OnElementChanged(ElementChangedEventArgs e) - { - base.OnElementChanged(e); - - if (Control == null) - { - var scroller = new NSScrollView - { - AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable, - DocumentView = _nsTableView = new NSTableView().AsListViewLook() - }; - - _nsTableView.RowHeight = 60; - SetNativeControl(scroller); - } - - if (e.OldElement != null) - { - // unsubscribe - } - - if (e.NewElement != null) - { - // subscribe - - var s = new NativeiOSListViewSource(e.NewElement, _nsTableView); - _nsTableView.Source = s; - } - } - - protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) - { - base.OnElementPropertyChanged(sender, e); - - if (e.PropertyName == NativeListView.ItemsProperty.PropertyName) - { - // update the Items list in the UITableViewSource - var s = new NativeiOSListViewSource(Element, _nsTableView); - _nsTableView.Source = s; - } - } - - public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) - { - return Control.GetSizeRequest(widthConstraint, heightConstraint, 44, 44); - } - } - - public class NativeListViewRenderer : ViewRenderer - { - public NativeListViewRenderer() - { - } - NSTableView table; - protected override void OnElementChanged(ElementChangedEventArgs e) - { - base.OnElementChanged(e); - - if (Control == null) - { - var scroller = new NSScrollView - { - AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable, - DocumentView = table = new NSTableView().AsListViewLook() - }; - - table.RowHeight = 60; - - SetNativeControl(scroller); - } - - if (e.OldElement != null) - { - // unsubscribe - } - - if (e.NewElement != null) - { - // subscribe - - var s = new NativeListViewSource(e.NewElement, table); - table.Source = s; - } - } - - protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) - { - base.OnElementPropertyChanged(sender, e); - - if (e.PropertyName == NativeListView.ItemsProperty.PropertyName) - { - // update the Items list in the UITableViewSource - var s = new NativeListViewSource(Element, table); - table.Source = s; - } - } - - public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint) - { - return Control.GetSizeRequest(widthConstraint, heightConstraint, 44, 44); - } - } - - public class NativeiOSListViewSource : NSTableViewSource - { - IList _tableItems; - NativeListView2 _listView; - readonly NSTableView _nsTableView; - readonly NSString _cellIdentifier = new NSString("TableCell"); - - public IEnumerable Items - { - set { _tableItems = new List(value); } - } - - public NativeiOSListViewSource(NativeListView2 view, NSTableView nsTableView) - { - _tableItems = new List(view.Items); - _listView = view; - _nsTableView = nsTableView; - } - - public override nint GetRowCount(NSTableView tableView) - { - return _tableItems.Count; - } - - public override void SelectionDidChange(NSNotification notification) - { - var selectedRow = (int)_nsTableView.SelectedRow; - if (selectedRow == -1) - return; - _listView.NotifyItemSelected(_tableItems[selectedRow]); - Console.WriteLine("Row " + selectedRow.ToString() + " selected"); - _nsTableView.DeselectRow(selectedRow); - } - - public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) - { - NativeMacOsCell cell = tableView.MakeView(_cellIdentifier, tableView) as NativeMacOsCell; - - if (cell == null) - { - cell = new NativeMacOsCell(_cellIdentifier); - } - int rowNumber = (int)row; - if (string.IsNullOrWhiteSpace(_tableItems[rowNumber].ImageFilename)) - { - cell.UpdateCell(_tableItems[rowNumber].Name - , _tableItems[rowNumber].Category - , null); - } - else - { - cell.UpdateCell(_tableItems[rowNumber].Name - , _tableItems[rowNumber].Category - , new NSImage("Images/" + _tableItems[rowNumber].ImageFilename + ".jpg")); - } - - return cell; - } - } - - public class NativeListViewSource : NSTableViewSource - { - // declare vars - IList _tableItems; - string _cellIdentifier = "TableCell"; - NativeListView _listView; - readonly NSTableView _nsTableView; - - public IEnumerable Items - { - set - { - _tableItems = new List(value); - } - } - - public NativeListViewSource(NativeListView view, NSTableView nsTableView) - { - _tableItems = new List(view.Items); - _listView = view; - _nsTableView = nsTableView; - } - - public override nint GetRowCount(NSTableView tableView) - { - return _tableItems.Count; - } - - public override void SelectionDidChange(NSNotification notification) - { - var selectedRow = (int)_nsTableView.SelectedRow; - if (selectedRow == -1) - return; - _listView.NotifyItemSelected(_tableItems[selectedRow]); - Console.WriteLine("Row " + selectedRow.ToString() + " selected"); - _nsTableView.DeselectRow(selectedRow); - } - - public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) - { - var cell = tableView.MakeView(_cellIdentifier, tableView); - - if (cell == null) - { - cell = new NSView(new CGRect(0, 0, tableView.Frame.Width, tableView.RowHeight)); - var textLabel = new NSTextField(new CGRect(1, 1, tableView.Frame.Width, tableView.RowHeight - 10)); - cell.AddSubview(textLabel); - } - var label = cell.Subviews[0] as NSTextField; - label.StringValue = _tableItems[(int)row]; - return cell; - } - } - - public class NativeMacCellRenderer : ViewCellRenderer - { - static NSString s_rid = new NSString("NativeCell"); - - public NativeMacCellRenderer() - { - } - - public override NSView GetCell(Cell item, NSView reusableView, NSTableView tv) - { - var x = (NativeCell)item; - Console.WriteLine(x); - - NativeMacOsCell c = reusableView as NativeMacOsCell; - - if (c == null) - { - c = new NativeMacOsCell(s_rid); - } - - NSImage i = null; - if (!string.IsNullOrWhiteSpace(x.ImageFilename)) - { - i = new NSImage("Images/" + x.ImageFilename + ".jpg"); - } - - base.WireUpForceUpdateSizeRequested(item, c, tv); - - c.UpdateCell(x.Name, x.Category, i); - - return c; - } - } - - public class NativeMacOsCell : NSView - { - NSTextField _headingLabel; - NSTextField _subheadingLabel; - NSImageView _imageView; - - public NativeMacOsCell() : this(new NSString("NativeMacOsCell")) - { - } - public NativeMacOsCell(NSString cellId) - { - Identifier = cellId; - WantsLayer = true; - Layer.BackgroundColor = NSColor.FromRgb(218, 255, 127).CGColor; - - _imageView = new NSImageView(); - - _headingLabel = new NSTextField() - { - Font = NSFont.FromFontName("Cochin-BoldItalic", 22f), - TextColor = NSColor.FromRgb(127, 51, 0), - BackgroundColor = NSColor.Clear - }; - - _subheadingLabel = new NSTextField() - { - Font = NSFont.FromFontName("AmericanTypewriter", 12f), - TextColor = NSColor.FromRgb(38, 127, 0), - Alignment = NSTextAlignment.Center, - BackgroundColor = NSColor.Clear - }; - - AddSubview(_headingLabel); - AddSubview(_subheadingLabel); - AddSubview(_imageView); - } - - public void UpdateCell(string caption, string subtitle, NSImage image) - { - _imageView.Image = image; - _headingLabel.StringValue = caption; - _subheadingLabel.StringValue = subtitle; - } - - public override void Layout() - { - base.Layout(); - - _imageView.Frame = new CGRect(Bounds.Width - 63, 5, 33, 33); - _headingLabel.Frame = new CGRect(5, 4, Bounds.Width - 63, 25); - _subheadingLabel.Frame = new CGRect(100, 18, 100, 20); - } - } - - public static class NSTableViewExtensions - { - public static NSTableView AsListViewLook(this NSTableView self) - { - self.SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.SourceList; - - self.AllowsColumnReordering = false; - self.AllowsColumnResizing = false; - self.AllowsColumnSelection = false; - - //this is needed .. can we go around it ? - self.AddColumn(new NSTableColumn("1")); - //this line hides the header by default - self.HeaderView = null; - return self; - } - } - -} diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Info.plist b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Info.plist deleted file mode 100644 index df587a637249..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Info.plist +++ /dev/null @@ -1,41 +0,0 @@ - - - - - CFBundleName - Xamarin.Forms.ControlGallery.MacOS - CFBundleIdentifier - com.xamarin.xamarin-forms-controlgallery-macos - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSMinimumSystemVersion - 10.10 - CFBundleDevelopmentRegion - en - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - APPL - CFBundleSignature - ???? - NSHumanReadableCopyright - rmarinho - NSPrincipalClass - NSApplication - XSAppIconAssets - Assets.xcassets/AppIcons.appiconset - LSApplicationCategoryType - public.app-category.developer-tools - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - NSMainStoryboardFile - Main - ATSApplicationFontsPath - Fonts - - diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Main.cs b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Main.cs deleted file mode 100644 index b5a9d6191232..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Main.cs +++ /dev/null @@ -1,13 +0,0 @@ -using AppKit; - -namespace Xamarin.Forms.ControlGallery.MacOS -{ - static class MainClass - { - static void Main(string[] args) - { - NSApplication.Init(); - NSApplication.Main(args); - } - } -} diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Main.storyboard b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Main.storyboard deleted file mode 100644 index 567816295cd8..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Main.storyboard +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/NativeServices.cs b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/NativeServices.cs deleted file mode 100644 index e0a303b24f8b..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/NativeServices.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.IO; -using AppKit; -using Xamarin.Forms; -using Xamarin.Forms.ControlGallery.MacOS; -using Xamarin.Forms.Controls; -using Xamarin.Forms.Platform.MacOS; -using IOPath = System.IO.Path; - -[assembly: Dependency(typeof(TestCloudService))] -[assembly: Dependency(typeof(CacheService))] -[assembly: Dependency(typeof(NativeColorService))] -[assembly: ExportRenderer(typeof(DisposePage), typeof(DisposePageRenderer))] -[assembly: ExportRenderer(typeof(DisposeLabel), typeof(DisposeLabelRenderer))] - -namespace Xamarin.Forms.ControlGallery.MacOS -{ - public class CacheService : ICacheService - { - public void ClearImageCache() - { - var documents = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - var cache = IOPath.Combine(documents, ".config", ".isolated-storage", "ImageLoaderCache"); - foreach (var file in Directory.GetFiles(cache)) - { - File.Delete(file); - } - } - } - - public class NativeColorService : INativeColorService - { - public Color GetConvertedColor(bool shouldCrash) - { - if (shouldCrash) - return NSColor.ControlText.ToColor(); - - return NSColor.ControlText.ToColor(NSColorSpace.DeviceRGBColorSpace); - } - } - - public class DisposePageRenderer : PageRenderer - { - protected override void Dispose(bool disposing) - { - if (disposing) - { - ((DisposePage)Element).SendRendererDisposed(); - } - base.Dispose(disposing); - - } - } - - public class DisposeLabelRenderer : LabelRenderer - { - protected override void Dispose(bool disposing) - { - - if (disposing) - { - ((DisposeLabel)Element).SendRendererDisposed(); - } - base.Dispose(disposing); - } - } - - public class TestCloudService : ITestCloudService - { - public bool IsOnTestCloud() - { - var isInTestCloud = Environment.GetEnvironmentVariable("XAMARIN_TEST_CLOUD"); - - return isInTestCloud != null && isInTestCloud.Equals("1"); - } - - public string GetTestCloudDeviceName() - { - return Environment.GetEnvironmentVariable("XTC_DEVICE_NAME"); - } - - public string GetTestCloudDevice() - { - return Environment.GetEnvironmentVariable("XTC_DEVICE"); - } - } -} - diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/PlatformSpecificCoreGalleryFactory.cs b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/PlatformSpecificCoreGalleryFactory.cs deleted file mode 100644 index 0bfe0e7996c1..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/PlatformSpecificCoreGalleryFactory.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using Xamarin.Forms; -using Xamarin.Forms.ControlGallery.MacOS; -using Xamarin.Forms.Controls; - -[assembly: Dependency(typeof(PlatformSpecificCoreGalleryFactory))] - -namespace Xamarin.Forms.ControlGallery.MacOS -{ - public class PlatformSpecificCoreGalleryFactory : IPlatformSpecificCoreGalleryFactory - { - public string Title => "macOS Core Gallery"; - - public IEnumerable<(Func Create, string Title)> GetPages() - { - return null; - } - } -} diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/RegistrarValidationService.cs b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/RegistrarValidationService.cs deleted file mode 100644 index c529b7cfa923..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/RegistrarValidationService.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Xamarin.Forms; -using Xamarin.Forms.ControlGallery.MacOS; -using Xamarin.Forms.Controls; -using Xamarin.Forms.Platform.MacOS; - -[assembly: Dependency(typeof(RegistrarValidationService))] -namespace Xamarin.Forms.ControlGallery.MacOS -{ - public class RegistrarValidationService : IRegistrarValidationService - { - public bool Validate(VisualElement element, out string message) - { - message = "Success"; - - if (element == null) - return true; - - var renderer = Platform.MacOS.Platform.CreateRenderer(element); - - if (renderer == null - || renderer.GetType().Name == "DefaultRenderer" - ) - { - message = $"Failed to load proper macOS renderer for {element.GetType().Name}"; - return false; - } - - return true; - } - } -} \ No newline at end of file diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/SampleNativeControl.cs b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/SampleNativeControl.cs deleted file mode 100644 index 4806264d13fd..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/SampleNativeControl.cs +++ /dev/null @@ -1,24 +0,0 @@ -using AppKit; -using Xamarin.Forms; -using Xamarin.Forms.ControlGallery.MacOS; -using Xamarin.Forms.Controls.Issues.Helpers; -using Xamarin.Forms.Platform.MacOS; - -[assembly: Dependency(typeof(SampleNativeControl))] -namespace Xamarin.Forms.ControlGallery.MacOS -{ - public class SampleNativeControl : ISampleNativeControl - { - public View View - { - get - { - var uiLabel = new NSTextField - { - StringValue = "Sample Native Control" - }; - return uiLabel.ToView(); - } - } - } -} \ No newline at end of file diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/SeparatorMenuItem.cs b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/SeparatorMenuItem.cs deleted file mode 100644 index 7e754ef70a93..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/SeparatorMenuItem.cs +++ /dev/null @@ -1,10 +0,0 @@ - -namespace Xamarin.Forms.ControlGallery.MacOS -{ - /// - /// Represents a separator menu item - /// - public class SeparatorMenuItem : MenuItem - { - } -} diff --git a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Xamarin.Forms.ControlGallery.MacOS.csproj b/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Xamarin.Forms.ControlGallery.MacOS.csproj deleted file mode 100644 index 5c7589714645..000000000000 --- a/src/Compatibility/ControlGallery/src/Xamarin.Forms.ControlGallery.MacOS/Xamarin.Forms.ControlGallery.MacOS.csproj +++ /dev/null @@ -1,410 +0,0 @@ - - - - - Debug - AnyCPU - {8D3DFCB7-DB10-40E5-ACFE-411AAA85520D} - {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Exe - Xamarin.Forms.ControlGallery.MacOS - Xamarin.Forms.ControlGallery.MacOS - v2.0 - Xamarin.Mac - Resources - - - true - full - false - bin\Debug - DEBUG;HAVE_OPENTK - prompt - 4 - false - false - Mac Developer - false - false - false - true - true - true - - - - - - - - - true - - - true - bin\Release - HAVE_OPENTK - prompt - 4 - false - true - Developer ID Application - true - false - true - true - true - SdkOnly - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {CB9C96CE-125C-4A68-B6A1-C3FF1FBF93E1} - Xamarin.Forms.Controls - - - {57B8B73D-C3B5-4C42-869E-7B2F17D354AC} - Xamarin.Forms.Core - - - {7D13BAC2-C6A4-416A-B07E-C169B199E52B} - Xamarin.Forms.Maps - - - {D31A6537-ED9C-4EBD-B231-A8D4FE44126A} - Xamarin.Forms.Platform - - - {C0059C45-EA1E-42F3-8A0E-794BB547EC3C} - Xamarin.Forms.Platform.MacOS - - - {9DB2F292-8034-4E06-89AD-98BBDA4306B9} - Xamarin.Forms.Xaml - - - {C3C24A6D-2D0C-4053-9FCC-E54FF9CA1884} - Xamarin.Forms.Maps.MacOS - - - - - Resources\about.png - - - Resources\about%402x.png - - - Resources\blog.png - - - Resources\blog%402x.png - - - Resources\facebook.png - - - Resources\facebook%402x.png - - - Resources\favorite.png - - - Resources\googleplus.png - - - Resources\googleplus%402x.png - - - Resources\hm_full.jpg - - - Resources\hm.png - - - Resources\hm%402x.png - - - Resources\home.png - - - Resources\ic_pause.png - - - Resources\ic_pause%402x.png - - - Resources\ic_play.png - - - Resources\ic_play%402x.png - - - Resources\ic_share.png - - - Resources\ic_share%402x.png - - - Resources\ic_stop.png - - - Resources\ic_stop%402x.png - - - Resources\instagram.png - - - Resources\instagram%402x.png - - - Resources\lists.png - - - Resources\messages.png - - - Resources\notifications.png - - - Resources\profile.png - - - Resources\ratchet_full.jpg - - - Resources\ratchet.png - - - Resources\ratchet%402x.png - - - Resources\refresh.png - - - Resources\refresh%402x.png - - - Resources\reply.png - - - Resources\retweet.png - - - Resources\rui.jpg - - - Resources\scott.png - - - Resources\scott159.png - - - Resources\search.png - - - Resources\slideout.png - - - Resources\slideout%402x.png - - - Resources\tdl_full.jpg - - - Resources\tdl.png - - - Resources\tdl%402x.png - - - Resources\tweet.png - - - Resources\twitter.png - - - Resources\twitter%402x.png - - - Resources\twitternav.png - - - Resources\twitternav%402x.png - - - Resources\xamarinlogo.png - - - Resources\bank.png - - - Resources\bank%402x.png - - - Resources\calculator.png - - - Resources\calculator%402x.png - - - Resources\coffee%402x.png - - - Resources\cover1.jpg - - - Resources\cover1small.jpg - - - Resources\crimson.jpg - - - Resources\crimsonsmall.jpg - - - Resources\Goobuntu-icon.png - - - Resources\Intranet-icon.png - - - Resources\local.html - - - Resources\menuIcon.png - - - Resources\menuIcon%402x.png - - - Resources\move_slider_one_right_ios6_iphone.base64 - - - Resources\move_slider_three_right_ios6_iphone.base64 - - - Resources\move_slider_two_right_ios6_iphone.base64 - - - Resources\oasis.jpg - - - Resources\oasissmall.jpg - - - Resources\photo.jpg - - - Resources\seth.png - - - Resources\seth%402x.png - - - Resources\settings%402x.png - - - Resources\test.jpg - - - Resources\toolbar_close.png - - - Resources\coffee.png - - - Images\FlowerBuds.jpg - - - Images\FlowerBuds%402x.jpg - - - Images\Fruits.jpg - - - Images\Fruits%402x.jpg - - - Images\Legumes.jpg - - - Images\Legumes%402x.jpg - - - Images\Vegetables.jpg - - - Images\Vegetables%402x.jpg - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - - - - - \ No newline at end of file