Beispiel #1
0
 public NamedSizeAttribute(TargetIdiom idiom, Type target, NamedSize whenSize, double isSize)
 {
     Idiom    = idiom;
     Target   = target;
     WhenSize = whenSize;
     IsSize   = isSize;
 }
 public static void Init(string runtimePlatform = "Test", TargetIdiom idiom = default(TargetIdiom))
 {
     Device.PlatformServices = new PlatformServices(runtimePlatform);
     Device.Idiom            = idiom;
     DependencyService.Register <SystemResourcesProvider>();
     DependencyService.Register <Serializer>();
     DependencyService.Register <ValueConverterProvider>();
     OpenUriAction = null;
 }
Beispiel #3
0
 public static void Init(string runtimePlatform = "Test", TargetIdiom idiom = default(TargetIdiom), OSAppTheme requestedTheme = OSAppTheme.Unspecified)
 {
     Device.PlatformServices = new PlatformServices(runtimePlatform, requestedTheme);
     Device.Idiom            = idiom;
     Device.Info             = new MockDeviceInfo();
     DependencyService.Register <SystemResourcesProvider>();
     DependencyService.Register <Serializer>();
     DependencyService.Register <ValueConverterProvider>();
     OpenUriAction = null;
 }
Beispiel #4
0
 public void RegisterView <TViewModel, TView>(TargetIdiom idiom = TargetIdiom.Phone)
     where TViewModel : ViewModel
     where TView : VisualElement
 {
     try
     {
         ViewRegister.ExportedViews.Add(new ExportedView(typeof(TView), typeof(TViewModel), idiom));
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #5
0
        public void OnIdiomExtension(string markup, TargetIdiom idiom, int expected)
        {
            Device.SetIdiom(idiom);
            var actual = (new MarkupExtensionParser()).ParseExpression(ref markup, new Internals.XamlServiceProvider(null, null)
            {
                IXamlTypeResolver   = typeResolver,
                IProvideValueTarget = new MockValueProvider("foo", new object())
                {
                    TargetProperty = GetType().GetProperty(nameof(FontSize))
                }
            });

            Assert.AreEqual(expected, actual);
        }
Beispiel #6
0
        public static void Init(PlatformBase platform, TargetIdiom idiom)
        {
            Platform = platform;
            platform.Init(idiom);
            Device.OS    = TargetPlatform.Other;
            Device.Idiom = idiom;

            Registrar.RegisterAll(new[] {
                typeof(ExportRendererAttribute)
            });
            NamedSizes.Register();

            Forms.IsInitialized = true;
        }
Beispiel #7
0
        public async Task NavigationUses_IdiomSpecificView(Type viewType, TargetIdiom idiom)
        {
            Device.SetIdiom(idiom);
            var initializer = new XunitPlatformInitializer(_testOutputHelper);
            var app         = new PrismApplicationMockPlatformAware(initializer);

            Assert.True(app.Initialized);
            await app.NavigationService.NavigateAsync("AutowireView");

            Assert.IsType(viewType, app.MainPage);
            Assert.IsType <AutowireViewModel>(app.MainPage.BindingContext);

            Device.SetIdiom(TargetIdiom.Unsupported);
        }
        private DataTemplate _GetTemplateForIdiom(TargetIdiom idiom)
        {
            switch (idiom)
            {
            case TargetIdiom.Desktop:
                return(_TakeFirstNonNull(ContentTemplateIdiomDesktop, ContentTemplateIdiomDefault));

            case TargetIdiom.Phone:
                return(_TakeFirstNonNull(ContentTemplateIdiomPhone, ContentTemplateIdiomDefault));

            case TargetIdiom.Tablet:
                return(_TakeFirstNonNull(ContentTemplateIdiomTablet, ContentTemplateIdiomDefault));

            case TargetIdiom.TV:
                return(_TakeFirstNonNull(ContentTemplateIdiomTV, ContentTemplateIdiomDefault));

            case TargetIdiom.Watch:
                return(_TakeFirstNonNull(ContentTemplateIdiomWatch, ContentTemplateIdiomDefault));
            }
            return(ContentTemplateIdiomDefault);
        }
Beispiel #9
0
        public static Page ResolvePageModel(Type type, object data, FreshBasePageModel pageModel)
        {
            //First get current platform
            TargetIdiom currentIdiom = Device.Idiom;
            Type        pageType;

            //First update namespace for directory mapping
            string baseName = type.AssemblyQualifiedName.Replace(".PageModel", ".Page").Replace(".ViewModel", ".Page");
            string name;

            switch (currentIdiom)
            {
            case TargetIdiom.Unsupported:
                //Look for a generic version
                name     = baseName.Replace("PageModel", "Page").Replace("ViewModel", "Page");
                pageType = Type.GetType(name);
                if (pageType == null)
                {
                    throw new Exception(name + " not found");
                }
                break;

            case TargetIdiom.Phone:
                //Look for a phone version
                name     = baseName.Replace("PageModel", "PhonePage").Replace("ViewModel", "PhonePage");
                pageType = Type.GetType(name);
                if (pageType == null)
                {
                    //Look for a generic version
                    var name1 = baseName.Replace("PageModel", "Page").Replace("ViewModel", "Page");
                    pageType = Type.GetType(name);
                    if (pageType == null)
                    {
                        throw new Exception(name + " not found");
                    }
                }
                break;

            case TargetIdiom.Tablet:
                //Look for a tablet version
                name     = baseName.Replace("PageModel", "TabletPage").Replace("ViewModel", "TabletPage");
                pageType = Type.GetType(name);
                if (pageType == null)
                {
                    //Look for a generic version
                    name     = baseName.Replace("PageModel", "Page").Replace("ViewModel", "Page");
                    pageType = Type.GetType(name);
                    if (pageType == null)
                    {
                        throw new Exception(name + " not found");
                    }
                }
                break;

            case TargetIdiom.Desktop:
                //Look for a desktop version
                name     = baseName.Replace("PageModel", "DesktopPage").Replace("ViewModel", "DesktopPage");
                pageType = Type.GetType(name);
                if (pageType == null)
                {
                    //Look for a tablet version
                    name     = baseName.Replace("PageModel", "TabletPage").Replace("ViewModel", "TabletPage");
                    pageType = Type.GetType(name);
                    if (pageType == null)
                    {
                        //Look for a generic version
                        name     = baseName.Replace("PageModel", "Page").Replace("ViewModel", "Page");
                        pageType = Type.GetType(name);
                        if (pageType == null)
                        {
                            throw new Exception(name + " not found");
                        }
                    }
                }
                break;

            case TargetIdiom.TV:
                //Look for a generic version
                name     = baseName.Replace("PageModel", "Page").Replace("ViewModel", "Page");
                pageType = Type.GetType(name);
                if (pageType == null)
                {
                    throw new Exception(name + " not found");
                }
                break;

            case TargetIdiom.Watch:
                //Look for a generic version
                name     = baseName.Replace("PageModel", "Page").Replace("ViewModel", "Page");
                pageType = Type.GetType(name);
                if (pageType == null)
                {
                    throw new Exception(name + " not found");
                }
                break;

            default:
                //Look for a generic version
                name     = baseName.Replace("PageModel", "Page").Replace("ViewModel", "Page");
                pageType = Type.GetType(name);
                if (pageType == null)
                {
                    throw new Exception(name + " not found");
                }
                break;
            }

            var page = (Page)FreshIOC.Container.Resolve(pageType);

            BindingPageModel(data, page, pageModel);

            return(page);
        }
Beispiel #10
0
 public ExportedView(Type viewType, Type viewModelType, TargetIdiom targetIdom)
 {
     this.TargetIdom = targetIdom;
     this.ViewModelType = viewModelType;
     this.ViewType = viewType;
 }
Beispiel #11
0
 public override void Init(TargetIdiom idiom)
 {
     SetServices(new EtoServices());
     UI.Init();
 }
 public ExportRendererAttribute(Type handler, Type target, Type[] supportedVisuals, TargetIdiom targetIdiom) : base(handler, target, supportedVisuals)
 {
     Target = targetIdiom;
 }
 public ExportRendererAttribute(Type handler, Type target, TargetIdiom targetIdiom) : this(handler, target, null, targetIdiom)
 {
 }
Beispiel #14
0
 public ExportedView(Type viewType, Type viewModelType, TargetIdiom targetIdom)
 {
     this.TargetIdom    = targetIdom;
     this.ViewModelType = viewModelType;
     this.ViewType      = viewType;
 }
Beispiel #15
0
 public abstract void Init(TargetIdiom idiom);
 public static void Init(string runtimePlatform = null, TargetIdiom idiom = TargetIdiom.Unsupported)
 {
     Device.SetIdiom(idiom);
     Device.PlatformServices = new MockPlatformServices(runtimePlatform);
 }
Beispiel #17
0
 public void SetUp()
 {
     defaultIdiom = Device.Idiom;
 }
Beispiel #18
0
 public static void SetTargetIdiom(TargetIdiom value) => Idiom = value;
Beispiel #19
0
 public MockDeviceInfo(string platform = null, TargetIdiom idiom = TargetIdiom.Unsupported, DeviceType?deviceType = null)
 {
     RuntimePlatform = platform;
     TargetIdiom     = idiom;
     DeviceType      = deviceType ?? DeviceType.Unknown;
 }