66using System ;
77using System . Reactive . Linq ;
88using System . Reflection ;
9- #if HAS_WINUI
9+ #if WINUI_TARGET
1010using Microsoft . UI . Xaml ;
1111using Windows . Foundation ;
12+ #endif
1213
14+ #if IS_WINUI
1315namespace ReactiveUI . WinUI ;
1416#endif
15- #if HAS_MAUI
17+ #if IS_MAUI
1618using System . ComponentModel ;
1719using Microsoft . Maui . Controls ;
1820
@@ -27,13 +29,15 @@ public class ActivationForViewFetcher : IActivationForViewFetcher
2729{
2830 /// <inheritdoc/>
2931 public int GetAffinityForView ( Type view ) =>
30- #if HAS_WINUI
31- typeof ( FrameworkElement ) . GetTypeInfo ( ) . IsAssignableFrom ( view . GetTypeInfo ( ) )
32+ #if WINUI_TARGET
33+ #if IS_MAUI
34+ typeof ( Page ) . GetTypeInfo ( ) . IsAssignableFrom ( view . GetTypeInfo ( ) ) ||
3235#endif
33- #if HAS_MAUI
34- typeof ( Page ) . GetTypeInfo ( ) . IsAssignableFrom ( view . GetTypeInfo ( ) ) ||
36+ typeof ( FrameworkElement ) . GetTypeInfo ( ) . IsAssignableFrom ( view . GetTypeInfo ( ) )
37+ #else
38+ typeof ( Page ) . GetTypeInfo ( ) . IsAssignableFrom ( view . GetTypeInfo ( ) ) ||
3539 typeof ( View ) . GetTypeInfo ( ) . IsAssignableFrom ( view . GetTypeInfo ( ) ) ||
36- typeof ( Cell) . GetTypeInfo( ) . IsAssignableFrom( view . GetTypeInfo ( ) )
40+ typeof ( Cell ) . GetTypeInfo ( ) . IsAssignableFrom ( view . GetTypeInfo ( ) )
3741#endif
3842 ? 10 : 0 ;
3943
@@ -42,10 +46,12 @@ public IObservable<bool> GetActivationForView(IActivatableView view)
4246 {
4347 var activation =
4448 GetActivationFor ( view as ICanActivate ) ??
45- #if HAS_WINUI
49+ #if WINUI_TARGET
4650 GetActivationFor ( view as FrameworkElement ) ??
51+ #if IS_MAUI
52+ GetActivationFor ( view as Page ) ??
4753#endif
48- #if HAS_MAUI
54+ #else
4955 GetActivationFor ( view as Page ) ??
5056 GetActivationFor ( view as View ) ??
5157 GetActivationFor ( view as Cell ) ??
@@ -55,9 +61,10 @@ public IObservable<bool> GetActivationForView(IActivatableView view)
5561 return activation . DistinctUntilChanged ( ) ;
5662 }
5763
58- private static IObservable < bool > ? GetActivationFor ( ICanActivate ? canActivate ) => canActivate ? . Activated . Select ( _ => true ) . Merge ( canActivate . Deactivated . Select ( _ => false ) ) ;
64+ private static IObservable < bool > ? GetActivationFor ( ICanActivate ? canActivate ) =>
65+ canActivate ? . Activated . Select ( _ => true ) . Merge ( canActivate . Deactivated . Select ( _ => false ) ) ;
5966
60- #if HAS_MAUI
67+ #if ! WINUI_TARGET || ( WINUI_TARGET && IS_MAUI )
6168 private static IObservable< bool > ? GetActivationFor( Page ? page )
6269 {
6370 if ( page is null)
@@ -85,7 +92,9 @@ public IObservable<bool> GetActivationForView(IActivatableView view)
8592
8693 return appearing. Merge ( disappearing ) ;
8794 }
95+ #endif
8896
97+ #if ! WINUI_TARGET
8998 private static IObservable< bool > ? GetActivationFor ( View ? view )
9099 {
91100 if ( view is null)
@@ -135,14 +144,12 @@ public IObservable<bool> GetActivationForView(IActivatableView view)
135144
136145 return appearing. Merge ( disappearing ) ;
137146 }
138- #endif
139-
140- #if HAS_WINUI
141- private static IObservable< bool > GetActivationFor ( FrameworkElement ? view )
147+ #else
148+ private static IObservable< bool > ? GetActivationFor ( FrameworkElement ? view )
142149 {
143150 if ( view is null)
144151 {
145- return Observable < bool > . Empty ;
152+ return null ;
146153 }
147154
148155 var viewLoaded = Observable. FromEvent < TypedEventHandler < FrameworkElement , object > , bool > (
0 commit comments