Skip to content

iOS Slider numberOfDiscreteValues fix #395

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

Conversation

dangrima90
Copy link
Contributor

@dangrima90 dangrima90 commented Jun 25, 2022

Here's a small fix on iOS so that numberOfDiscreteValues has the correct value.

With the previous logic the slider resulted in always being continuous as it calculated the min/max difference rather than the amount of values in the range.

Examples

Range 0 - 10
Steps 1

Calculation 10 - 0 / 1 = 10
New Calculation (10 - 0 + 1) / 1 = 11


Range 5 - 100
Steps 5
Calculation 100 - 5 / 5 = 19
New Calculation (100 - 5 + 1) / 5 = 20 (Actual value is 19.2 but code is using Math.ceil() to get a whole number)


Tested this locally on my project, unfortunately I wasn't able to run the demo apps within this project itself. But I think it should be fine.

Let me know if any other updates are required.

@farfromrefug
Copy link
Member

@dangrima90 thanks that looks good!
BTW what was your error with the demo app?

@farfromrefug farfromrefug merged commit 76e2052 into nativescript-community:master Jun 26, 2022
@dangrima90
Copy link
Contributor Author

I've ran into an issue when trying to run npm run build.all. Not sure if it's something related to my local environment. Here's the error I'm seeing - it's always getting stuck on some angular project (not always the same one):

lerna notice cli v5.1.6
lerna info Executing command in 18 packages: "npm run build.all"
lerna info run Ran npm script 'build.all' in '@nativescript-community/ui-material-core' in 12.8s:

> @nativescript-community/[email protected] build.all /Code/ui-material-components/packages/core
> npm run build


> @nativescript-community/[email protected] build /Code/ui-material-components/packages/core
> npm run tsc


> @nativescript-community/[email protected] tsc /Code/ui-material-components/packages/core
> ../../node_modules/.bin/cpy '**/*.d.ts' '../../packages/core' --cwd=../../src/core --parents && ../../node_modules/.bin/tsc -d

lerna info run Ran npm script 'build.all' in '@nativescript-community/ui-material-snackbar' in 43.5s:

> @nativescript-community/[email protected] build.all /Code/ui-material-components/packages/snackbar
> npm run build


> @nativescript-community/[email protected] build /Codeui-material-components/packages/snackbar
> npm run tsc


> @nativescript-community/[email protected] tsc /Code/ui-material-components/packages/snackbar
> ../../node_modules/.bin/cpy ../../src/snackbar/snackbar.d.ts ./ && ../../node_modules/.bin/tsc -d

lerna info run Ran npm script 'build.all' in '@nativescript-community/ui-material-core-tabs' in 48.5s:

> @nativescript-community/[email protected] build.all /Code/ui-material-components/packages/core-tabs
> npm run build


> @nativescript-community/[email protected] build /Code/ui-material-components/packages/core-tabs
> npm run tsc 


> @nativescript-community/[email protected] tsc /Code/ui-material-components/packages/core-tabs
> ../../node_modules/.bin/cpy '**/*.d.ts' '../../packages/core-tabs' --cwd=../../src/core-tabs --parents && ../../node_modules/.bin/tsc -d

lerna ERR! npm run build.all exited 1 in '@nativescript-community/ui-material-floatingactionbutton'
lerna ERR! npm run build.all stdout:

> @nativescript-community/[email protected] build.all /Code/ui-material-components/packages/floatingactionbutton
> npm run build && npm run build.angular


> @nativescript-community/[email protected] build /Code/ui-material-components/packages/floatingactionbutton
> npm run tsc


> @nativescript-community/[email protected] tsc /Code/ui-material-components/packages/floatingactionbutton
> ../../node_modules/.bin/cpy ../../src/floatingactionbutton/floatingactionbutton.d.ts ./ && ../../node_modules/.bin/tsc -d


> @nativescript-community/[email protected] build.angular /Code/ui-material-components/packages/floatingactionbutton
> ../../node_modules/.bin/ng-packagr -p ../../src/floatingactionbutton/angular/package.json -c ../../src/floatingactionbutton/angular/tsconfig.json

Building Angular Package

------------------------------------------------------------------------------
Building entry point '@nativescript-community/ui-material-floatingactionbutton-angular'
------------------------------------------------------------------------------
lerna ERR! npm run build.all stderr:
WARNING: Found configuration in /Code/ui-material-components/src/floatingactionbutton/angular/package.json.
Configuring ng-packagr in "package.json" is deprecated. Use "ng-package.json" instead.
(node:6533) ExperimentalWarning: The ESM module loader is experimental.
- Compiling with Angular sources in Ivy full compilation mode.
✖ Compiling with Angular sources in Ivy full compilation mode.
The requested module 'sourcemap-codec' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'sourcemap-codec';
const { decode, encode } = pkg;
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @nativescript-community/[email protected] build.angular: `../../node_modules/.bin/ng-packagr -p ../../src/floatingactionbutton/angular/package.json -c ../../src/floatingactionbutton/angular/tsconfig.json`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @nativescript-community/[email protected] build.angular script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/dg/.npm/_logs/2022-06-26T11_11_56_799Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @nativescript-community/[email protected] build.all: `npm run build && npm run build.angular`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @nativescript-community/[email protected] build.all script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/dg/.npm/_logs/2022-06-26T11_11_56_867Z-debug.log
lerna ERR! npm run build.all exited 1 in '@nativescript-community/ui-material-floatingactionbutton'
lerna WARN complete Waiting for 12 child processes to exit. CTRL-C to exit immediately.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @nativescript-community/[email protected] build.all: `lerna run build.all`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @nativescript-community/[email protected] build.all script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/dg/.npm/_logs/2022-06-26T11_11_57_028Z-debug.log

@dangrima90 dangrima90 deleted the fix/ios-slider-number-of-discrete-values branch June 26, 2022 11:16
@farfromrefug
Copy link
Member

@dangrima90 ok it is weird as it works here but your angular version is too "new" and does not support the current repo structure

@dangrima90
Copy link
Contributor Author

@farfromrefug understood 👍 it's my first time setting up this project on my machine so it could be that it's a recent angular change. It could be that on your environment if you clean your node modules you might get the same issue?

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

Successfully merging this pull request may close these issues.

2 participants