Skip to content
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

RadDatForm styling is not working #260

Open
jmdavid opened this issue Apr 8, 2020 · 9 comments
Open

RadDatForm styling is not working #260

jmdavid opened this issue Apr 8, 2020 · 9 comments
Assignees
Labels

Comments

@jmdavid
Copy link

jmdavid commented Apr 8, 2020

  • CLI: 6.5.0
  • Android Runtime: 10
  • Plugin(s): "nativescript-ui-dataform": "^6.0.0",

In my project, I use themes:

@import "~@nativescript/theme/core";

In one of my components, I use RadDataForm.
For picker input, the arrow is hidden.
I cannot apply TKPropertyEditorStyle, it is ignored completely.

<TKEntityProperty tkDataFormProperty name="name" displayName="Name" index="0>
     <TKPropertyEditor tkEntityPropertyEditor type="Text">
        <TKPropertyEditorStyle tkPropertyEditorStyle strokeColor="#00695c" strokeWidth="2" fillColor="#4db6ac" labelHidden="false"
                labelTextSize="18" ios:labelFontName="Times New Roman" android:labelFontName="sans-serif-light" labelFontStyle="Italic"
                labelPosition="Top" labelTextColor="#00695c">
        </TKPropertyEditorStyle>
    </TKPropertyEditor>
</TKEntityProperty>

nsbug

If I import compat (@import "~@nativescript/theme/core.compat";), it works.

So there is an incompatibility with new themes and Rad component.
How can I fix it without using old compat (that makes my app ugly)?

Thanks.

@jmdavid
Copy link
Author

jmdavid commented Apr 10, 2020

Here are the steps to reproduce.

> tns create bugng --template tns-template-drawer-navigation-ng
    found 6 vulnerabilities (5 moderate, 1 high)
> npm audit fix
    3 vulnerabilities required manual review and could not be updated
    1 package update for 1 vulnerability involved breaking changes
> npm audit fix --force
> tns plugin add nativescript-ui-dataform

Then, in app.module.ts, added:

import { NativeScriptFormsModule } from "nativescript-angular/forms";
  ...
  imports: [
    ...
    NativeScriptFormsModule
  ]

Then, in home.module.ts, added:

import { NativeScriptUIDataFormModule } from "nativescript-ui-dataform/angular";
  ...
  imports: [
    ...
    NativeScriptUIDataFormModule
  ]

home.component.ts :

import { Component, OnInit, ViewChild } from "@angular/core";
import { RadSideDrawer } from "nativescript-ui-sidedrawer";
import * as app from "tns-core-modules/application";
import { RadDataFormComponent } from "nativescript-ui-dataform/angular/dataform-directives";

@Component({
    selector: "Home",
    templateUrl: "./home.component.html"
})
export class HomeComponent implements OnInit {

    @ViewChild('myCommitDataForm', { static: false }) myCommitDataFormComp: RadDataFormComponent;
    private _person: Person;

    constructor() {
        // Use the component constructor to inject providers.
    }

    ngOnInit(): void {
        this._person = new Person("John", 23, "[email protected]", -1);
    }

    onDrawerButtonTap(): void {
        const sideDrawer = <RadSideDrawer>app.getRootView();
        sideDrawer.showDrawer();
    }

    public onPropertyCommitted(args) {
        console.log(args.propertyName);
        if (this.myCommitDataFormComp.dataForm.editedObject) {
            console.log(this.myCommitDataFormComp.dataForm.editedObject);
        }
    }

    get person(): Person {
        return this._person;
    }
}

class Person {
    constructor(public name: string, public age: number, public email: string, public city?: number) { }
}

home.component.html :

<ActionBar>
    <NavigationButton ios:visibility="collapsed" icon="res://menu" (tap)="onDrawerButtonTap()"></NavigationButton>
    <ActionItem icon="res://menu" android:visibility="collapsed" (tap)="onDrawerButtonTap()"
        ios.position="left">
    </ActionItem>
    <Label text="Home"></Label>
</ActionBar>

<GridLayout class="nt-form" rows="132,auto,auto,*">
    <Image height="128" src="res://logo"></Image>
    <Label row="1" class="page__content-placeholder" text="<!-- Page content goes here -->"></Label>
    <RadDataForm row="2" #myCommitDataForm [source]="person" tkExampleTitle tkToggleNavButton commitMode="Immediate" (propertyCommitted)="onPropertyCommitted($event)">
        <!-- >> angular-dataform-adjustment-html -->
        <TKEntityProperty tkDataFormProperty name="name" displayName="Name" index="0">
            <TKPropertyEditor tkEntityPropertyEditor type="Text">
                <TKPropertyEditorStyle tkPropertyEditorStyle strokeColor="#00695c" strokeWidth="2" fillColor="#4db6ac" labelHidden="false"
                labelTextSize="18" ios:labelFontName="Times New Roman" android:labelFontName="sans-serif-light" labelFontStyle="Italic"
                labelPosition="Top" labelTextColor="#00695c"></TKPropertyEditorStyle>
            </TKPropertyEditor>
            <TKNonEmptyValidator tkEntityPropertyValidators errorMessage="Username can't be empty."></TKNonEmptyValidator>
        </TKEntityProperty>
        <TKEntityProperty tkDataFormProperty name="age" displayName="Age" index="1">
            <TKPropertyEditor tkEntityPropertyEditor type="Number"></TKPropertyEditor>
        </TKEntityProperty>
        <TKEntityProperty tkDataFormProperty name="email" displayName="E-Mail" index="2">
            <TKPropertyEditor tkEntityPropertyEditor type="Email"></TKPropertyEditor>
        </TKEntityProperty>
        <TKEntityProperty tkDataFormProperty name="city" displayName="City" index="3" valuesProvider="Montreal, Quebec, Toronto" hintText="city">
            <TKPropertyEditor tkEntityPropertyEditor type="Picker"></TKPropertyEditor>
            <TKNonEmptyValidator tkEntityPropertyValidators errorMessage="City can't be empty."></TKNonEmptyValidator>
        </TKEntityProperty>
    </RadDataForm>
</GridLayout>

@bundyo bundyo self-assigned this Apr 12, 2020
@bundyo bundyo added the bug label Apr 12, 2020
@jmdavid
Copy link
Author

jmdavid commented Apr 22, 2020

I haven't tested on iOS so far, I did and it works.
So the bug is only in Android.

@bundyo
Copy link
Contributor

bundyo commented May 27, 2020

Looks like just setting background-color or border to the text fields will reset all borders and the dropdown caret. Unfortunately removing those styles will break the dark mode styling, as the border and the dropdown caret remain black. So this looks more like a styling bug in RadDataForm.

As for the text field text styling - this is a bug/design decision in {N} - CSS styling has more priority than the properties of the control, so it won't be applied. You can override it with CSS with higher specificity. Something along those lines:

.ns-root PropertyEditor[type='Text'] DataFormEditorLabel {
    font-size: 18;
    font-style: italic;
    color: #00695c;
    position: top;
}

.ns-root PropertyEditor[type='Text'] DataFormEditorCore {
    border-color: #00695c; 
    border-width: 2;
    background-color: #4db6ac;
}

@bundyo
Copy link
Contributor

bundyo commented May 27, 2020

For just Android, like this:

.ns-android PropertyEditor[type='Text'] DataFormEditorLabel {
    font-size: 18;
    font-style: italic;
    color: #00695c;
    position: top;
}

@houssammehdi
Copy link

All my RadDataForms started to look like this suddenly.

Is this the same problem?

https://github.com/NativeScript/NativeScript/issues/8607#issue-629523503

Is there a way to remove those styles being applied?

@bundyo
Copy link
Contributor

bundyo commented Jun 4, 2020

Yes, looks like it.

@houssammehdi
Copy link

@bundyo is there a way to disable all this styling? I want my fields to have the default look on iOS. I've been looking everywhere with no hope, if I create a new project and add RadDataForm it doesn't look like the image shown at all. (My github issue ref)

@bundyo
Copy link
Contributor

bundyo commented Jul 3, 2020

You can try if compat mode helps, but I guess not completely.

Maybe I can separate the {N}-UI components styling in a separate file that can be optionally not loaded. What do you think?

@gustavotrott
Copy link

For me it is caused by the @import '@nativescript/theme/css/core.css';.

specifically this style:

PickerField, DatePickerField, TimePickerField, DateTimePickerFields, DataFormEditorCore, RadAutoCompleteTextView {
  background-repeat: no-repeat;
  background-position: right center
}

But I'm not able to fix it... if I set any background* style to DataFormEditorCore, it stops showing the caret.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants