Is there a way to set auto refresh the jetpack compose preview? - android

I just started to use the Jetpack compose toolkit. I added the #Preview and a set showBackground = true, showSystemUi = true as parameters and it works really good. But every time i add or change something it doesn't auto refresh by itself, so i have to do it manually.

as Raul text, padding and some other things update automatically, but **
make sure you have live edit of literals on
**.
But soon Live edit of composables, not just literals (Int, String, Dp...) will be available, :
read more here

for the static resources like text, color the UI updates automatically, as it does on the running application, but for the structural components you need to rebuild the project and the changes apply automatically in the preview as well.

Some Components auto-refresh on version 1.1.1

Related

is there hot reload in Jetpack like flutter?

any idea to make android studio Jetpack compose auto refresh like Hot reload in Flutter it's annoying! Is there Auto-refresh in Jetpack Compose viewer?
Right now, compose does not support Hot reloads.
But Literals values can be updated directly.
Some supported types.
Int
String
Color
Dp
Boolean
You can view constant literals that trigger real-time updates without the compilation step by enabling these highlighted values.
Reference
When Android Studio Electric Eel becomes stable, Live Edit is enabled by default that acts as Hot Reload. Right now its still on preview.

Jetpack Compose - The preview does not render in real-time

I use Compose with AS Arctic Fox v2020.3.1. When I update the code, the preview does not render in real-time. AS show the message "The preview is out of date" and I must click "Build & Refresh". I'd like it to render UI in real-time, similar to XML Design.
How do it?
Thanks in advance.
AFAIK you can't. You're able to edit string values and certain others, such as padding dp's but when adding or removing elements, you have to rebuild to view the updated layout.

Old / dark dialog boxes when using TStyleBook

This problem is highly related to the following question: Why are all the dialogs are using the "old" Android 2.x style?
I'm using Delphi Berlin (10.1), where this problem has been fixed already:
But, as soon as a TStyleBook is dropped to the form and assigned to it (e. g. by right clicking a component and then "edit custom style"), the dialog boxes (all of them) turn to the dark style again:
The automatically created "trimmed" style is still the "light" version ("AndroidL Light"). And yes, I checked that function "GetNativeTheme()" in FMX.Helpers.Android.pas assigns the Result, I even copied the file and added it to the project. Removing the assignment from Form1.StyleBook show the native styled dialogs again.
How can this be solved while still keep using a TStyleBook?
I found the problem: Function GetNativeTheme() was searching with TStyleManager.FindStyleDescriptor() in the assigned style for a TStyleDescription object entry, to look if one of the strings "[LIGHTSTYLE]" or "[DARKSTYLE]" is used for the target platform. In a full style file this object entry is normally present, but when starting to edit a custom style of a component inside the IDE, a TStyleBook component is created with just a small style. It cannot be seen inside the IDE, but this small style does not contain the TStyleDescription object entry, so the dark/light theme can not be found out. And by default, the GetThemeFromDescriptor() returns 0, which seems to correspond to the dark/old style.
I solved the problem by double-clicking the TStyleBook component, save the style to a file (*.style), opened the file in a text editor and simply manually added the TStyleDescription object entry. Saved and loaded back to the IDE. Now all dialogs use the correct light style theme.
Here again as text:
object TStyleDescription
StyleName = 'Description'
Author = 'Embarcadero Technologies Inc.'
AuthorURL = 'www.embarcadero.com'
PlatformTarget = '[ANDROID][ANDROIDL][LIGHTSTYLE][DEFINEFONTSTYLES]'
MobilePlatform = True
Title = 'AndroidL Light'
Version = '1.0'
end
In addition to StanE's answer:
Instead of adding a StyleDescription to all custom styles you can also modify the GetThemeFromDescriptor() function in FMX.Helpers.Android to return a default value of TJAlertDialog.JavaClass.THEME_HOLO_LIGHT.

ios version of themes and styles

As an Android developer new to iOS/swift, I am trying to implement a global theme/style which every view controller can inherit. I expect one file which I can modify which would affect all View Controllers's UI. This is possible in android. Does iOS have anything similar?
The best match for what you are looking for is probably UIAppearance, although not quite the same.
What it allows you to do is basically setup each component once, and then have that be the default look for all other components.
An example for setting button colors (you could do this in your AppDelegate):
UIButton.appearance().setTitleColor(.white, forState: .normal)
UIButton.appearance().backgroundColor = .blue
Try looking at these tutorials:
https://www.raywenderlich.com/108766/uiappearance-tutorial
http://blog.iseinc.biz/use-uiappearance-create-ios-app-themes
Usually if you want to do something like that, you can go to the AppDelegate File, and add code like the ones below:
[[UITextField appearance] setTintColor:[UIColor redColor]];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
For example textfield by default has a bluish tint color, but with the code above, the default tint color becomes red. The single line of code you place will affect all UI related to it. Try it out.

Dynamic colours in an app

I have colors of text and button come dynamic form backend,
I need to change this color of text dynamically when change happens in backend all at time.
I could make it manual
textView.setTextColor(getResources().getColor(R.color.text_color));
Is there a way to change group of text color dynamically or must set every text color manually in code?
I searched for how to change theme colors dynamically at run time and i found this answer this answer.
But I also search again and I found this github
but it doesn't work on Android Marshmallow (6.0+) and it's use is discouraged! as he say.
Is there any lib or method to change the theme on runtime?
So far it's impossible and not viable because of themes are immutable.
GreenMatter becomes outdated so regretfully the answer of your question is No way.
More precisely, the color overriding at runtime is not working. There is no fix found at the moment. The future of this feature is uncertain.

Categories

Resources