alexrainman / nativescript-carousel-view

CarouselView plugin for NativeScript
MIT License
16 stars 5 forks source link

Carousel view always takes 100% of the screen height #9

Closed terreb closed 7 years ago

terreb commented 7 years ago

nativescript 2.3.0 tns-core-modules 2.3.0 tns-ios 2.3.0 nativescript-carousel-view 2.0.1 simulator iOS 9.3

How to reproduce:

  1. in demo app first install nativescript-carousel-view v 2.0.1 from npm
  2. change all references to npm module (this is for clean test since I don't know what version is in the local folder by default)
  3. Change main-page.xml to:
<Page
  xmlns="http://schemas.nativescript.org/tns.xsd"
  xmlns:controls="nativescript-carousel-view"
  navigatingTo="navigatingTo">

  <ActionBar title="Demo"/>

  <GridLayout rows="100 * 50">
      <controls:CarouselView row="0" id="carouselView" position="0" height="100" templateSelector="{{ templateSelector }}" itemsSource="{{ itemsSource }}"/>
      <Label text="TEST" row="1" height="100%" backgroundColor="red"/>
      <GridLayout row="2" columns="50, *, 50" rows="*" style.backgroundColor="lightgray">
          <Label tap="onPrev" text="Prev" row="0" col="0" style.textAlignment="center" style.verticalAlignment="center"/>
          <Label text="Add page" id="addPage" row="0" col="1" style.textAlignment="center" style.verticalAlignment="center"/>
          <Label tap="onNext" text="Next" row="0" col="2" style.textAlignment="center" style.verticalAlignment="center"/>
      </GridLayout>
  </GridLayout>

</Page>
  1. Change slider-view.xml as the following:
<StackLayout loaded="onLoaded" orientation="horizontal" backgroundColor="blue">
    <Label text="{{ first }}"/> 
    <Label text="{{ last }}"/>
    <Button text="Remove me" tap="buttonTap"/> 
</StackLayout>
  1. Run the app

You should notice that labels and button inside slide are hidden under the middle red view (label test). If you comment that view out you will see them. If you try to swipe left the slider at the middle of the screen (at the level of the labels and button) it won't work. Only if you swipe it on top within first 100dpi below actionbar it will work.

Expected behaviour:

  1. The height of the slider (blue view) should be 100dpi (because height is set to 100)
  2. Labels and button should be within the slide
  3. Swipe work at any point inside slide

Please let me know if you require more info on this.

alexrainman commented 7 years ago

Because you are declaring grid rows in wrong way. I just tested and it works like a charm. CarouselView behaves like any other {N} view.

rows="100,*,50"
screen shot 2016-11-09 at 9 36 35 am
terreb commented 7 years ago

FYI: rows=""100 * 50" or rows="100,*,50" are both correct declaration. Let me share my repo with you to see the issue. Probably there is something else that lead to that issue.

alexrainman commented 7 years ago

You may be doing something wrong in your side. I just tested and it works. As i said, CarouselView behaves like any other {N} view.

terreb commented 7 years ago

First off, as I see you didn't copy the code I mention above:

<StackLayout loaded="onLoaded" orientation="horizontal" backgroundColor="blue">
    <Label text="{{ first }}"/> 
    <Label text="{{ last }}"/>
    <Button text="Remove me" tap="buttonTap"/> 
</StackLayout>

Can you do this?

alexrainman commented 7 years ago

I did exactly what you are reporting.

terreb commented 7 years ago

It's not blue and orientated horizontally on your screenshot.

terreb commented 7 years ago

Can you run this please https://github.com/terreb/nativescript-carousel-view-test to see what I mean?

alexrainman commented 7 years ago

Blue and oriented horizontally? I dont know what you are trying to do.

alexrainman commented 7 years ago

I can do that with the view but it will work also

terreb commented 7 years ago

First, I'm trying to set orientation of inner views (labels and button) inside slide horizontally. Second I'm setting blue color to make it obvious that the slider takes more than 100dpi on the screen. If you comment out the following:

<Label text="TEST" row="1" height="100%" backgroundColor="red"/>

...you should notice that.

Please run the code from my repo and see there. It's a your code bit changed, but there you should see the issue.

terreb commented 7 years ago

Have you had time to run the code from my repo and see the issue with the plugin?

alexrainman commented 7 years ago

I dont need to. I followed what you did:

Everything works as expected. You must be doing something wrong on your end.

About horizontal stacklayout? No ide why it doesnt works. Use a grid instead.

alexrainman commented 7 years ago

I couldnt reproduce your issue with my own code. Will run your repo and find out the issue you are facing or what you are doing wrong. Thanks

alexrainman commented 7 years ago

I downloaded and run your repo. The plugin works as expected. I added interPageSpacing to illustrate that i can swipe between pages but elements inside each view are not requesting height in iOS. Horizontal StackLayout issue, not the plugin itself.

screen shot 2016-11-10 at 6 11 38 pm screen shot 2016-11-11 at 7 57 30 am
terreb commented 7 years ago

Hmm, strange, I changed the layout of the slide to GridLayout, but still unable to make the slide to take 100dpi in height:

screen shot 2016-11-12 at 11 23 25 am

If I put

<Label text="test" height="100" row="0" backgroundColor="blue"/>

instead of

<controls:CarouselView row="0" id="carouselView" position="0" templateSelector="{{ templateSelector }}" height="100" itemsSource="{{ itemsSource }}"/>

it takes 100dpi as expected:

screen shot 2016-11-12 at 11 24 05 am

I pushed this to my test repo, could you please have a look when you have time? What is incorrect there and how do I set the slider's height?

terreb commented 7 years ago

the plugin version is 2.0.4

alexrainman commented 7 years ago

I see you are declaring height="100" in the CarouselView xml. I cannot reproduce your problem even with your repo.