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

Optimize App size: Convert PNG Images into SVG or Vector Icons #164

Open
rn-chris opened this issue Jun 1, 2022 · 5 comments
Open

Optimize App size: Convert PNG Images into SVG or Vector Icons #164

rn-chris opened this issue Jun 1, 2022 · 5 comments

Comments

@rn-chris
Copy link

rn-chris commented Jun 1, 2022

  • Remove useless icon, images.
  • Convert image icons into vector icons.
  • Replace png files into svg files.
@rn-chris rn-chris moved this to Concept/User Story in Development Jun 1, 2022
@rn-chris rn-chris moved this from Concept/User Story to In Progress in Development Jun 1, 2022
@rn-chris
Copy link
Author

rn-chris commented Jun 3, 2022

I completed for removing icons first,
So I will try for removing images from now.

@ildaneta
Copy link
Contributor

ildaneta commented Jun 12, 2022

My suggestion to this issue was to utilize personalized svg's. Why?

First because we can have svg personalized to the app, which is impossible to have using libraries as vector icons.

To make this implementation is necessary:

Step I

yarn add react-native-svg

Step II

yarn add --dev react-native-svg-transformer

Step III

Insert inside metro.config.js

const { getDefaultConfig } = require("expo/metro-config");

module.exports = (async () => {
  const {
    resolver: { sourceExts, assetExts }
  } = await getDefaultConfig(__dirname);
  return {
    transformer: {
      babelTransformerPath: require.resolve("react-native-svg-transformer")
    },
    resolver: {
      assetExts: assetExts.filter(ext => ext !== "svg"),
      sourceExts: [...sourceExts, "svg"]
    }
  };
})();

I tried to make this config inside Whisper wallet code, but as we already have one config to use @ui-kitten I had some troubles.

Step IV

  • Create a folder to types -> @types
  • Create inside it a file called svg.d.ts and insert the code bellow:
declare module "*.svg" {
  import React from 'react'
  import { SvgProps } from 'react-native-svg'

  const content: JSX.Element<SVGProps>

  export default content
}

With all the previous steps performed we can use svg as a module, with that, inside our code we can create a folder to svg's, import svg files and use it in our code as a component:

import ArrowLeftSVG from '../../images/arrow-left.svg';


const App = () => {
  ...
  return (<ArrowLeftSVG /> )
}

@aguycalled
Copy link
Member

There is already some work about this issue on pr #167. But I think eventually removing the kitten dependency would be good. What do you think?

@ildaneta
Copy link
Contributor

ildaneta commented Jun 12, 2022

If we can remove the Kitten dependency I won't more problems to use that solution.
I'll try this approach. @aguycalled

I saw the #167 pull request, but I really think that we can use better ways to do this migration from png to svg.

What I need to have permission to submit pull request?

@aguycalled
Copy link
Member

perfect! we can take your path then.

you can just fork the repository and open a pull request. thanks!

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

No branches or pull requests

3 participants