Enforcing theme for a particular Xamarin application - xamarin

In my Xamarin project (Xamarin 4.8) there are many pages with complex structure. Also there are many bitmap resources, designed for white backgrounds etc.
When user sets Dark theme on the iOS, appearance of pages become weird and unusable. On Android the application looks as nothing was changed.
For now I have no time, to set manually color properties on every control on every page and I would like to enforce light theme for the application (Android and iOS platforms), to get a time to redesign the whole application later.
In an article I read that Xamarin 5 offers a way, putting this line of code into Application class:
App.Current.UserAppTheme = OSAppTheme.Light;
I tried this way (migrated project to Xamarin 5 and called this code), but it does not work. Application on iOS in the Dark theme looks unusable.
What options do I have on this point? Is there a relatively simple way to enforce Light theme for iOS applications?

As advised by #SushiHangover and #JackHua-MSFT into this answer I used the following approach and it worked (XCode 12.3):
Into the plist.info I should add the key UIUserInterfaceStyle with value Light. And that enforces Light theme for the application, regardless of what theme is set for the device.
Final xml code, that I added to plist.info looks like that:
<key>UIUserInterfaceStyle</key>
<string>Light</string>

Related

Xamarin forms iOS default mail app Behavior

As per the requirement of the project I need to have the page which should behave as the default Apple Mail app on the iPhone.
Attaching a gif that I have created for the same.
I tried using the plug in https://github.com/rotorgames/Rg.Plugins.Popup
but I couldn't achieve the exact same behavior where the background shrinks and expands as the modal pop up is dragged.Any leads, examples or demos will be really helpful.
Note: I am using Xamarin.Forms.
With the new Xamain Forms update. i.e. after iOS13
The model behavior has became the default model behavior for Xamarin iOS.
When you do.
Navigation.PushModalAsyn(<your_page_here>).
It gives the above (gif) behavior.

Is the social boo theme dead in codenameone?

I've been struggling with app dialog and toolbar appearances in the social boo theme for some time. I recently discovered that my struggles are less with my code and more with the theme. In the GUI Builder switching the Native Themes from IOS6, IOS7, and Android (Gingerbread I believe) all create very different dialogs ranging from matching to illegible to ok. Also I found this demo:
https://www.codenameone.com/demos-SocialBoo.html
and ran it on my Android (S6) phone. The below image illustrates the problems:
Social Boo visualizations
Note the Dialog's appearances as they change in the first 3 images. Please note in the 3rd Android picture I'm clicking on the Cancel button to show how differently it paints with the pointer pressed. The 4th image is again from my phone, note the toolbar button on the top right with a square image placed oddly over a rectangular button. Ah finally, all the problems I'm seeing in my app happening elsewhere!
Hopefully my title question now makes more sense. Is the social boo theme being updated with CodenameOne releases or is it dead? Should I abandon using it as it'll have quite varied appearances on devices especially iOS? I'd love to have the theme maintain the IOS6 appearance on all devices - how can I achieve that goal? Thank you in advance for your help!
It's a bit out of date. Most developers just cut a PSD design from scratch which works best when based on a native theme.
You can easily fix these things if you want to work with that theme though. When we implement a theme we don't aim to implement every feature that might be needed as those are hard to predict and will increase the theme size. The original theme didn't include design for dialogs so some behaviors leaked out.
You can use theme constants and UIID's like the theme constant dlgButtonCommandUIID to determine the UIID of the buttons within the dialog.

Xamarin.Forms: Styling is not the same for UWP, WinPhone

In Android looks like OK. But UWP looks ugly. Font-size is too big. Controls are too big.
But UWP app is bad:
Is it possible to make it a little bit the same. I understand it has different theme. But how I can overide it? Change font-size for whole app?
Checkout OnPlatform - it allows you to specify different values for different platforms. If you create some styles for your controls you can set the font size depending on platform using this trick.
There's an example of using OnPlatform on the Xam developer site, half way down this page:
https://developer.xamarin.com/guides/xamarin-forms/xaml/xaml-basics/essential_xaml_syntax/

How to incorporate new look and feel in android?

I'm coming from a web development background. I'n order to change the look and feel of the app I simply apply a new css to get the look and feel.
How can I do this in android?
The only think I can see is stencils? But I don't quite understand stencils?
Can I simply get hold of some file(s)/images and add it to the resources a suddenly my app looks stunning?
I'm really confused on how to do this?
The CSS equivalent in Android are Styles and Themes. You can then apply a style of any of your components (i.e., have all your TextViews have a particular look). You may consider looking at the output of the Android Asset Studio (particularly the Android Action Bar Style Generator and the Android Holo Colors Generator tools) as examples of styles and themes.
All layouts in android are made in xml files under the res/layoutfolders, but it's not as simple as changing a css files. All these xml files are connected to Java classes, where there may also be some layout changes.
You can edit colors and themes quite easily but you need some experience in native android development if you want to know what you're doing.

How to avoid theme (lite&dark) efects on windows phone applications?

I developed one Windows Phone 7 application.
After installed the app to my mobile device (in emulator too) I'm experiencing the theme problem.
Means there are two themes in windows phone, LITE and DARK.
When I set my theme to dark and execute my app , it looks OK,
but if I change the theme to LITE everything is reverted.
It means white lables become black, and black background become white.
So I need a solution to my app, so that the user can set any theme, but it doesn't effect the appearrence of application.
Don't hardcode colours, brushes, etc, but instead use {StaticResource ResourceName} and use resources from Theme Resources for Windows Phone
Make sure that every TextBlock and TextBox has a Style associated with it (available values from the same link)
If you have have custom resources (colours, images, etc) that you wish to be theme-aware you are free to use the ThemeResourceDictionary I posted on my blog (and also for this SO question). I promise to commit the code to GitHub one of these days and also create a NuGet package.

Resources