I am currently developing an app that I want to release for Android and IOS. My problem is that I don't want to use Material Design for both platforms, as that wouldn't match the IOS design language. Is there any way to use one codebase and compile it for Android using Material Design and for IOS using Cupertino? If not, what is the usual way to go?
Checkout: https://pub.dev/packages/flutter_platform_widgets
Its a library that has already done this for a bunch of widgets. If the library doesn't have something you want you can make use of the PlatformWidget from the library. Under the hood it will be doing something similar to fartem's answer.
You can build widgets tree with platform separation or move your widgets to a separated classes/files. Example:
Example with just if:
if (Platform.isAndroid) {
return Column(
// Android specific layout
);
} else {
return Column(
// iOS specific layout
);
}
Use "flutter_platform_widgets" where you can separate each widgets to Android & IOS
Related
An adaptive layout that is driven by the screen size. This is the basic idea and I use LayoutBuilderin the Flutter project, and how about in the Compose?
Checkout BoxWithConstraints.
It works very well.
My app has ChipGroups with individual Chips inside. (Documentation) and (Description)
What I want to do is to use Espresso libraries in Android to test the functionality of these components. I want to click on the Chips, especially their close buttons, to delete them and check that they were actually removed, etc. I have not been able to find information about iterating over ChipGroups like with using the foreach. The methods like Espresso.onView() or .perform() are missing this functionality. The closest I have come is seeing information on RecyclerViews and ListViews.
I have looked at the documentation here and the cheatsheet among others. Any idea what I ought to do to test these components?
As an option:
fun chipContainsText(text: String) {
onView(allOf(withText(containsString(text)), isAssignableFrom(Chip::class.java))).check(matches(isDisplayed()))
}
And I use it:
chipContainsText(1000)
In general, using isAssignableFrom(CLASS_NAME::class.java) is always very helpful in difficult situations.
Layout Screenshot:
The new Jetpack compose component added to Arch component is like Flutter Ui making.
How does it make the Ui though?
Does it use a native code engine like Skia, or it still follows the ViewGroup way like before?
Compose creates one view currently named AndroidComposeView, which inherits ViewGroup, and it draws the widget tree on its canvas. It also processes motion/keyboard events for this view.
There may be more helper views added to this view due to implementation details, but basically for the "widgets" of Compose, you won't see classical Views in view hierarchy. Layout inspector currently doesn't help for Compose - you can try it but you'll won't see your widgets.
Developers are promised to be able to create own customized widgets, which can directly paint on Canvas, set layout for itself or children, or process input events.
However, the Canvas and lots of other classes used here are not standard framework classes. For example, Canvas for Compose is redefined in Kotlin. Similar way there is new Paint, Shape, and other new classes. They internally use framework classes for their work, but that's implementation detail. When drawing, you'd use these new classes.
Since Compose is a library, and not present natively on Android devices, the library is included in each app that uses Compose.
Also there is no native code involved here, all is done in Kotlin and becomes part of your app's dexed code. By using Compose, your app won't contain any additional native library (probably, if creators don't change mind).
No, It doesn't use anything from the old UI Toolkit actually they are building it to overcome old UIToolkit's problems.
Compose is not views, It's a new set of Jetpack UI Widget, Basically, it's a Kotlin compiler plugin which renders the Android Canvas (I suppose there's no documentation for this yet) with full compatibility of existing android's view system, the last Dev summit there was a talk covers how it works internally, I/O had another talk too
I'm working on cross-platform mobile Unity application. I want add a switch on my screen allowing user turn on and off some functionality (like this: Android Material Switch).
As I know there is no native implementation of UI Switches in Unity. I found only this asset (Switch UI element) in Unity Asset Store, but it has really poor design.
So should I manually implement the Material Switch? Or is there anything in the web I can use in this case?
Thanks for response.
You can use slider as switch.
Here are simple steps:
Create a slider by going to GameObject->UI->Slider
Check whole numbers chech-box in slider component's inspector.
set min value to 0 and max value to 1.
Use whatever graphics you want (even from material design)
Register "OnValueChange" method to handle change in value:
public void SliderValueChanged(float value)
{
if(value == 0)
// off
else
// on
}
Probably I'm a bit late, but for anyone who is viewing this question, I found a fairly good (free) Asset called Lean GUI with switches and stuff.
Hope it'll help someone.
I am working on android app where I am thinking to develop reusable UI interface. How it can be developed and included in my .xml's
Here I want to develop a progress bar with my image and it will be display on some .xml's.
Please provide any code help.
I am a new in this field.
you can use <Include> xml tag within your layout xml,
read this :)
http://developer.android.com/resources/articles/layout-tricks-merge.html
I think you need to use styles and themes. Check this out.
You can either build custom (compound) views, look at Building Custom Components.
Or you can use Fragments. Fragments are new in Honeycomb (Android 3.0), but there is a compatibility library that adds fragment support to lower android versions (can be found in your ANDROID_SDK/extras/android folder). Or you can mix both of course.