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

feat(Bonus Pagamenti Digitali): [#175012088] Adds the AddBancomatScreen for Bancomat onboarding #2285

Merged
merged 68 commits into from
Oct 15, 2020

Conversation

CrisTofani
Copy link
Contributor

Short description

This PR adds the AddBancomatScreen for the Onboarding bancomat flow

fabriziofff and others added 30 commits September 29, 2020 10:41
@pagopa-github-bot pagopa-github-bot changed the title [#175012088] Adds the AddBancomatScreen for Bancomat onboarding feat(Bonus Pagamenti Digitali): [#175012088] Adds the AddBancomatScreen for Bancomat onboarding Oct 13, 2020
@pagopa-github-bot
Copy link
Collaborator

pagopa-github-bot commented Oct 13, 2020

Affected stories

  • 🌟 #175012088: Creare schermata per visualizzare e selezionare i bancomat trovati

Generated by 🚫 dangerJS against 0bcca39

@codecov-io
Copy link

codecov-io commented Oct 13, 2020

Codecov Report

Merging #2285 into master will decrease coverage by 0.00%.
The diff coverage is 28.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2285      +/-   ##
==========================================
- Coverage   47.95%   47.95%   -0.01%     
==========================================
  Files         560      561       +1     
  Lines       16166    16177      +11     
  Branches     3221     3221              
==========================================
+ Hits         7752     7757       +5     
- Misses       8372     8378       +6     
  Partials       42       42              
Impacted Files Coverage Δ
ts/components/screens/BaseHeader.tsx 25.51% <0.00%> (ø)
...onboarding/bancomat/components/BankPreviewItem.tsx 52.00% <25.00%> (+8.66%) ⬆️
...nboarding/bancomat/screens/hooks/useImageResize.ts 31.25% <31.25%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b8deb1...0bcca39. Read the comment docs.

addBancomat:
title: "Add bancomat {{current}} of {{length}}"
screenTitle: "Do you want to add this card?"
bodySingular: "Abbiamo trovato 1 carta a te intestata. Procedi con l'aggiunta di questa carta cliccando Aggiungi o clicca Salta per annullare l'operazione."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be in english

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Undermaken Yep, I noticed while developing the following story to connect the bancomat screen with redux, I'm going to fix this here too

screenTitle: "Vuoi aggiungere questa carta?"
bodySingular: "Abbiamo trovato 1 carta a te intestata. Procedi con l'aggiunta di questa carta cliccando Aggiungi o clicca Salta per annullare l'operazione."
bodyPlural: "Abbiamo trovato {{number}} carte a te intestate. Procedi con l'aggiunta di questa carta cliccando Aggiungi o clicca Salta per passare alla carta successiva."
skip: Skip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be in italian

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same for the previous comment

@@ -0,0 +1,46 @@
import { useEffect } from "react";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useImageResize.ts should be fine

}
};

export const useImageResize = (
Copy link
Contributor

@Undermaken Undermaken Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a callback we can use an internal state and return it.
Could this code be an improvement?

const handleImageDimensionSuccess = (
  width: number,
  height: number,
  maxW: number,
  maxH: number
): [number, number] => {
  if (width > 0 && height > 0) {
    const ratio = Math.min(maxW / width, maxH / height);
    return [width * ratio, height * ratio];
  }
  return [0, 0];
};

export const useImageResize = (
  maxWidth: number,
  maxHeight: number,
  imageUrl?: string
): [number, number] => {
  const [size, setSize] = useState<[number, number]>([0, 0]);
  useEffect(() => {
    fromNullable(imageUrl).map(url =>
      Image.getSize(url, (w, h) =>
        setSize(handleImageDimensionSuccess(w, h, maxWidth, maxHeight))
      )
    );
  }, [imageUrl]);
  return size;
};

usage

const imageDimensions = useImageResize(
    BASE_IMG_W,
    BASE_IMG_H,
    props.bank.logoUrl
  );

  const imageStyle: StyleProp<ImageStyle> = {
    width: imageDimensions[0],
    height: imageDimensions[1],
    resizeMode: "contain"
  };

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS I didn't test it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, maybe an external (from the component point of view) state could be useful, I'll give it a try

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Undermaken works delightfully, implemented in d6a39b2

@CrisTofani CrisTofani requested a review from Undermaken October 14, 2020 08:21
@Undermaken Undermaken merged commit d0767a8 into master Oct 15, 2020
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.

5 participants