forked from reactiveui/ReactiveUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Add support for Xamarin TV.OS (reactiveui#1706)
- Loading branch information
1 parent
0a75342
commit 2a067c0
Showing
33 changed files
with
182 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace EventBuilder.Platforms | ||
{ | ||
// ReSharper disable once InconsistentNaming | ||
public class TVOS : BasePlatform | ||
{ | ||
public override AutoPlatform Platform => AutoPlatform.TVOS; | ||
|
||
public TVOS(string referenceAssembliesLocation) | ||
{ | ||
if (PlatformHelper.IsRunningOnMono()) { | ||
var assembly = | ||
@"/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.TVOS10/Xamarin.TVOS10.dll"; | ||
Assemblies.Add(assembly); | ||
|
||
CecilSearchDirectories.Add(Path.GetDirectoryName(assembly)); | ||
} else { | ||
var assemblies = | ||
Directory.GetFiles(Path.Combine(referenceAssembliesLocation, "Xamarin.TVOS"), | ||
"Xamarin.TVOS.dll", SearchOption.AllDirectories); | ||
|
||
var latestVersion = assemblies.Last(); | ||
Assemblies.Add(latestVersion); | ||
|
||
CecilSearchDirectories.Add(Path.GetDirectoryName(latestVersion)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using UIKit; | ||
|
||
namespace ReactiveUI.Cocoa | ||
{ | ||
/// <summary> | ||
/// This class exists to force the MT linker to include properties called by RxUI via reflection | ||
/// </summary> | ||
[Preserve(AllMembers = true)] | ||
class LinkerOverrides | ||
{ | ||
public void KeepMe() | ||
{ | ||
// UIButon | ||
var btn = new UIButton(); | ||
var title = btn.Title(UIControlState.Disabled); | ||
btn.SetTitle("foo", UIControlState.Disabled); | ||
btn.TitleLabel.Text = btn.TitleLabel.Text; | ||
|
||
// UITextView | ||
var tv = new UITextView(); | ||
tv.Text = tv.Text; | ||
|
||
// UITextField | ||
var tf = new UITextField(); | ||
tv.Text = tf.Text; | ||
|
||
// var UIImageView | ||
var iv = new UIImageView(); | ||
iv.Image = iv.Image; | ||
|
||
// UI Label | ||
var lbl = new UILabel(); | ||
lbl.Text = lbl.Text; | ||
|
||
// UI Control | ||
var ctl = new UIControl(); | ||
ctl.Enabled = ctl.Enabled; | ||
ctl.Selected = ctl.Selected; | ||
|
||
EventHandler eh = (s, e) => { }; | ||
ctl.TouchUpInside += eh; | ||
ctl.TouchUpInside -= eh; | ||
|
||
// UIBarButtonItem | ||
var bbi = new UIBarButtonItem(); | ||
bbi.Clicked += eh; | ||
bbi.Clicked -= eh; | ||
|
||
eh.Invoke(null, null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Reflection; | ||
using UIKit; | ||
|
||
namespace ReactiveUI | ||
{ | ||
public class UIKitCommandBinders : FlexibleCommandBinder | ||
{ | ||
public static Lazy<UIKitCommandBinders> Instance = new Lazy<UIKitCommandBinders>(); | ||
|
||
public UIKitCommandBinders() | ||
{ | ||
Register(typeof(UIControl), 9, (cmd, t, cp) => ForTargetAction(cmd, t, cp, typeof(UIControl).GetRuntimeProperty("Enabled"))); | ||
Register(typeof(UIBarButtonItem), 10, (cmd, t, cp) => ForEvent(cmd, t, cp, "Clicked", typeof(UIBarButtonItem).GetRuntimeProperty("Enabled"))); | ||
} | ||
} | ||
} | ||
|
31 changes: 31 additions & 0 deletions
31
src/ReactiveUI/Platforms/tvos/UIKitObservableForProperty.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using UIKit; | ||
|
||
namespace ReactiveUI | ||
{ | ||
[Preserve] | ||
public class UIKitObservableForProperty : ObservableForPropertyBase | ||
{ | ||
public static Lazy<UIKitObservableForProperty> Instance = new Lazy<UIKitObservableForProperty>(); | ||
|
||
public UIKitObservableForProperty() | ||
{ | ||
Register(typeof(UIControl), "Value", 20, (s, p) => ObservableFromUIControlEvent(s, p, UIControlEvent.ValueChanged)); | ||
Register(typeof(UITextField), "Text", 30, (s, p) => ObservableFromNotification(s, p, UITextField.TextFieldTextDidChangeNotification)); | ||
Register(typeof(UITextView), "Text", 30, (s, p) => ObservableFromNotification(s, p, UITextView.TextDidChangeNotification)); | ||
Register(typeof(UISegmentedControl), "SelectedSegment", 30, (s, p) => ObservableFromUIControlEvent(s, p, UIControlEvent.ValueChanged)); | ||
Register(typeof(UISegmentedControl), "SelectedSegment", 30, (s, p) => ObservableFromUIControlEvent(s, p, UIControlEvent.ValueChanged)); | ||
|
||
// Warning: This will stomp the Control's delegate | ||
Register(typeof(UITabBar), "SelectedItem", 30, (s, p) => ObservableFromEvent(s, p, "ItemSelected")); | ||
|
||
// Warning: This will stomp the Control's delegate | ||
Register(typeof(UISearchBar), "Text", 30, (s, p) => ObservableFromEvent(s, p, "TextChanged")); | ||
} | ||
} | ||
} | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters