-
-
Notifications
You must be signed in to change notification settings - Fork 241
Screen Size Qualifiers not work in tns Angular project, only work in js project. #404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @Arthurisme, Screen Size Qualifiers are still not supported in NativeScript Angular projects. Such a feature would be available for some of the next nativescript-angular versions. As a temporary solution you could use |
+1 for this issue |
so may I guess... the file name resolver works at run time but with Angular 2, the css file name has to be specified at compile time... the styleUrls cannot be computed at run time... |
Any update regarding this ? This is quite of a key feature 👍 |
Currently we are evaluating how to support that. The main problem is that this feature cannot work with angular Ahead-Of-Time Compilation as in this case the template should be known at build time, but the screens size and orientation is something only available at runtime. |
We should evaluate implementing bootstrap-like responsive layout grid as available on the web. |
@vakrilov - community is asking where we are on this topic? ping ping? |
Just in case someone would only need tablet-specific CSS (like myself) and can't wait for an official solution (like myself), you can do: const isTablet: boolean = device.deviceType == DeviceType.Tablet;
@Component({
styleUrls: ['default.css', (isTablet ? 'tablet.css' : 'phone.css')]
}) |
Any update on when this feature is likely to be available? |
Just an update: |
Maybe the solution involves qualifying the selector as well @component({ You could then dynamically create a But then you'd need to declare the different versions in the module. Anyway, This is a solution you could use with out needing native script support built in, it would be a pain though. |
any new updates to issue? |
As this feature is not yet implemented and it took me a while to figure out how to do it (creating new component for each size didn't look maintainable to me), here is a little explanation. The ternary condition on scss import doesn't work well with webpack for me (because it would mean lazy loaded scss...) What you can do is: Create a .scss file for any of the size you want to handle (name them as you want, but let's keep the 'Screen Size Qualifiers' names for this example), which can result for a
In each of those files, you wrap all your classes in a specific class, e.g. You import all your files inside inside a single
Inside your component, you can reference ... html content
<ScrollView #scrollView>
... html content
</ScrollView>
... html content import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import * as platformModule from 'tns-core-modules/platform';
@Component({
selector: 'Home',
moduleId: module.id,
templateUrl: './home.component.html',
styleUrls: ['home.component.scss'],
})
export class HomeComponent implements OnInit {
@ViewChild('scrollView') scrollView: ElementRef;
constructor() {
/************************************************************
* Use the constructor to inject services.
*************************************************************/
}
ngOnInit(): void {
const className =
platformModule.screen.mainScreen.widthPixels >= 1440
? 'page-1440'
: platformModule.screen.mainScreen.widthPixels >= 1080
? 'page-1080'
: 'page-640';
const svElement = <ScrollView>this.scrollView.nativeElement;
svElement.className = className;
}
} |
This is a bit of a problem for me too... I really don't want to change to not using angular :-( and the other suggested "hacky" tricks aren't nice. I need a whole new template for screen sizes, not just minor style changes |
@trojanc You may try writing a directive that will inject / render right HTML template based on device width. |
Any updates on this issue? Thank you |
You may achieve this by creating a directive or simple ngIf. |
Update: It looks like supporting screen size qualifiers nearly impossible especially now that we have Angular AOT and webpack. There are a couple of solutions in this tread that you can use now. Also the same results would be possible when support for CSS media queries is implemented, so you might follow this issue instead. |
How to support multiple screen sizes in my NativeScript(with angular) app? |
any changes in the topic? |
It seems qualifiers also don't work i Vue Flavour |
From @Arthurisme on August 19, 2016 5:13
I use following names as Screen Size Qualifiers, but none of any one is working in tns angular project:
page.minWH600.html
page.minWH600.css
page.minWH600.ts
page.land.css
page.land.html
page.port.css
page.port.html
So is it because Screen Size Qualifiers not support angular project yet?
Copied from original issue: NativeScript/NativeScript#2604
The text was updated successfully, but these errors were encountered: