How to fix ViewBinding build error on CodeLab - android-viewbinding

I recently went through the Codelab to update my Navigation and found a Nice way to handle SplitScreens and smaller as well as Wider screens on Android using BottomNavigation alternating with Drawer depend on Screen layout!
Learn Jetpack Navigation Codelab for the Codelab
googlecodelabs /
android-navigation for the GitHub Code
However: Adopting this for ViewBinding present a problem that need fixing!
By Adding
buildFeatures {
dataBinding true
// for view binding:
viewBinding true
}
to the app:build.gradle and "Rebuild Project" yields an error
Configurations for navigation_activity.xml must agree on the root element's ID.
Missing ID:
- layout-w960dp
- layout-h470dp
#+id/drawer_layout:
- layout
The Issue is that There is No ID's for the alternative layouts matching the main layout, however they are purposly different to accomplish the task.
Can anyone Suggest a solve please

Related

Use Beamer package with Get package

So In general everything works for me, nevertheless I get an error in my console regarding Getx & Beamer types
Expected a value of type 'GetNavConfig', but got one of type
'RouteInformation'
I think that I know where the RouteInformation comes from:
List<BeamPage> buildPages(
BuildContext context, RouteInformationSerializable state) {
return [HomePage.beamLocation];
}
it is an argument of the buildPages() method, that has to be implimented due to the abstract Beamer class.
On the other hand I think that the
GetMaterialApp
expects a GetNavConfig, but gets a RouteInformation. Im not really sure whether the things that I interpreted are correct. So I have no idea how to do something against the error. How could I fix the problem?
Well, since you're trying to rely on the beamer package instead of the Getx routing management feature, then you do not need the GetMaterialApp, you need to just use the MaterialApp, and for the beamer you need to use the MaterialApp.router.
Getx is a package that offers separate features, you could get state management and dependency injection... working fine without GetMaterialApp.
However, this means that you will not be allowed to use navigation methods such as Get.to() and Get.toNamed(), you cannot use the Get.context, and you cannot use the Getx's bottom sheet and dialogs.

Best practice for switchable Vaadin 12 themes

I am currently in the process of migrating a Vaadin 8 application over to Vaadin 12. The look and feel should be used by the user and changed on Login or via a button press.
In Our Vaadin 8 application we had 2 themes (a dark and a light one), each with their own SASS/CSS and some shared properties. The user was able to switch it using the setTheme() Method. When a click to the switching button happened, the Look and Feel just changed. In Vaadin 12 the Theming follows a different approach and I am struggling to find a good way to implement this feature in Vaadin 12.
Let's say we don't want to create a whole new Theme and just want to use customized LUMO. I can set the Theme/Variant through the #Theme Annotation. The Downside: The Theme will be fixed at Runtime.
Also i could just write some code to apply variants to my application and components. (like in the dynamic styling chapter: https://vaadin.com/docs/flow/element-api/tutorial-dynamic-styling.html )
The Downside: It won't be very practicable to iterate through each element and apply the variant.
My question now:
What is the best way to achieve a switch between to themes at runtime? (customized light- and dark variants of Lumo or any other theme).
Would I just create 2 HTML Files (for compatibility) containing CSS and then somehow override the currently used File through a dynamic import?
I hope my question is clear and someone can point me to the right direction.
If you are only interested in toggling between light and dark, then you can just add/remove dark at a very high place in the DOM. E.g. the element of the UI is usually the body or at least very high up.
E.g.:
new Checkbox("Use Dark Theme").tap{
addValueChangeListener{ cb ->
getUI().ifPresent(){ ui ->
def themeList = ui.getElement().getThemeList()
if (cb.value) {
themeList.add(Lumo.DARK)
} else {
themeList.remove(Lumo.DARK)
}
}
}
}
edit
As asked in the comments of another answer:
To change the colors in a theme, you can override the used colors. This is the example how to change the text color for light and dark Lumo theme:
html {
--lumo-body-text-color: red;
}
[theme~="dark"] {
--lumo-body-text-color: yellow;
}
It's relatively easy to switch between two different variants of the same theme, e.g. the dark and light variants of Lumo. To do this, you only need to toggle the corresponding theme attribute on the <html> element. There's no direct access to that element from the server, but you can do it with a small snippet of JavaScript: ui.getPage().executeJavaScript("document.documentElement.setAttribute($0, $1)", "theme", "dark");
Depending on circumstances, you can or must apply the changes to the <body> element instead. In that case, you can either switch out .documentElement for .body in the JS snippet or directly use ui.getElement().setAttribute("theme", "dark") in Java.
Switching between two different base themes, e.g. Lumo vs Material is a much more complicated affair. For each component, there can only be one base theme loaded in the browser at the same time, and reloading the page is the only way of getting rid of the one that is already loaded. For each component that is used for Flow, the framework takes care of loading the right theme import in addition to the base import that doesn't have any styling. To make things even more complicated, the theme designated using #Theme is automatically included in the application's production bundle. To be able to use multiple base themes, you'd also have to somehow produce multiple different bundles and also somehow configure Flow to use the right bundle depending on circumstances.

Could not find a tree control for the tree

I am facing an error for sample code I am using angular 6 and angular material for application design:
<mat-tree>
<mat-tree-node> parent node </mat-tree-node>
</mat-tree>
Error Message:
Error: Could not find a tree control for the tree
any help much appreciated.
The documentation on Material Angular is not super clear about it...
You need tho specifie a [treeControl]="nestedTreeControl" of the type NestedTreeControl<FileNode>;
If you go to Material Angular Tree Component and check the code you will understand easily.
In case you really want to work with a flat tree then this error also appears when you accidentally use <mat-nested-tree-node> instead of <mat-tree-node>.

Xamarin NetStandard Android sfChart DateTimeStripLine not displayed?

This is fairly specific (as the title suggests).
I've recently ported my Xamarin Forms app to NETStandard, and now my sfChart DateTimeStripLine are not visible on Android.
Things show up more-or-less fine on UWP, so I don't think I've introduced regressions.
Anyone else having similar experiences? Has anyone successfully used ChartStripLine on NET Standard?
We have prepared a sample using DateTimeStripline in SfChart with .Net Standard 1.3 and it’s working fine in this sample. If still you face the problem, please provide Stripline related code snippet, it would be helpful to provide better solution.
So, finally figured out the issue:
The StripLines declared in XAML work fine, but binding to a StripLineCollection did not (android only). Unfortunately, declaring in XAML is not a particularly useful option.
To fix/workaround, declare StripLine in XAML like so:
<chart:DateTimeAxis x:Name="TheTimeAxis" ...>
<chart:DateTimeAxis.StripLines>
<!-- Empty def requires at least one item to be used
This creates container to fill in ViewModel.
Fixes dissappearing StripLines bug on android -->
<chart:DateTimeStripLine WidthType="Day" Width ="1"
Start="09/28/2017">
</chart:DateTimeStripLine >
</chart:DateTimeAxis.StripLines>
Then, in the code behind access the named axis, pull out the striplines and modify to your hearts content.
// Workaround Android: Our StripLines do not appear to be
// refreshing when bound from XAML. To fix we create in XAML,
// then retrieve the existing collection and pass that to the
// viewmodel for modification
DateTimeAxis sl = this.TheTimeAxis;
var slc = sl.StripLines;

Detecting unused methods iOS

Very simple question and hopefully isn't duplicated :).
The situation is following:
Project has been developing more then a year and by many developers.
From time to time I'm facing with unused methods (which are defined in .h and .m) obviously I'm not getting any warnings.
This is not critical, but I would like to have project cleared from all unnecessary staff. Of course I can search for all methods and define which are unused in project but I wonder if there is more elegant way?!
Thanks
A quick way to check while browsing your source code is the View > Standard Editor > Show Related Items menu (shortcut key: ^1). Place your cursor within a method body and then view the Callers.
AppCode (http://www.jetbrains.com/objc) can tell you if a method or an import is unused.
It's works in real time, but you can also inspect a whole project (menu code > inspect Code)
I don't think xCode can do it.
AppCode is not free, but it has a trial version.
Might I suggest adding an NSLOG to these methods. For example, if you have a View Controller called Home, you can go into the .m file for the Home View Controller and at the top of the function, write the following:
NSLOG(#"Method 1, has 3 buttons);
then watch the readout as you progress through the actions on that View Controller. The log should say something that would best describe the method in question. Step 2 would be to take the methods that you feel aren't showing up on the output and comment them out. That can be done by highlighting the method and then hitting Command + '/' on the keyboard. This will place '//' in front of each highlighted line commenting it out. Test your view controller again and if still no errors, you can delete that method. That's a free way to do it, but it does take some time.

Resources