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: add Custom Fonts and Expo Migration #163

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
contracts/contracts/RegisterASCII.txt
sdk/.env
dist
**/node_modules
**/node_modules/
showcase
33 changes: 30 additions & 3 deletions app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
import "react-native-get-random-values"
import "@ethersproject/shims"
import "react-native-get-random-values";
import "@ethersproject/shims";
import MainScreen from './src/screens/MainScreen';
import { Buffer } from 'buffer';
import { YStack } from 'tamagui';
Expand All @@ -9,13 +9,34 @@ import useNavigationStore from './src/stores/navigationStore';
import { AMPLITUDE_KEY } from '@env';
import * as amplitude from '@amplitude/analytics-react-native';
import useUserStore from './src/stores/userStore';
import * as Font from 'expo-font';
import AppLoading from 'expo-app-loading';

global.Buffer = Buffer;

const customFonts = {
'Lato-Bold': require('./assets/fonts/Lato-Bold.ttf'),
'Lato-BoldItalic': require('./assets/fonts/Lato-BoldItalic.ttf'),
'Lato-Italic': require('./assets/fonts/Lato-Italic.ttf'),
'Lato-Regular': require('./assets/fonts/Lato-Regular.ttf'),
'Luciole-Bold-Italic': require('./assets/fonts/Luciole-Bold-Italic.ttf'),
'Luciole-Bold': require('./assets/fonts/Luciole-Bold.ttf'),
'Luciole-Regular-Italic': require('./assets/fonts/Luciole-Regular-Italic.ttf'),
'Luciole-Regular': require('./assets/fonts/Luciole-Regular.ttf'),
};

function App(): JSX.Element {
const [fontsLoaded, setFontsLoaded] = React.useState(false);

const toast = useToastController();
const setToast = useNavigationStore((state) => state.setToast);
const initUserStore = useUserStore((state) => state.initUserStore);

const loadFonts = async () => {
await Font.loadAsync(customFonts);
setFontsLoaded(true);
};

useEffect(() => {
setToast(toast);
}, [toast, setToast]);
Expand All @@ -27,7 +48,13 @@ function App(): JSX.Element {
initUserStore();
}, []);

// TODO: when passportData already stored, retrieve and jump to main screen
useEffect(() => {
loadFonts();
}, []);

if (!fontsLoaded) {
return <AppLoading />;
}

return (
<YStack f={1} bc="#161616" h="100%" w="100%">
Expand Down
31 changes: 29 additions & 2 deletions app/app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
{
"name": "ProofOfPassport",
"displayName": "Proof of Passport"
"expo": {
"name": "ProofOfPassport",
"slug": "proof-of-passport",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.yourcompany.proofofpassport"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.yourcompany.proofofpassport"
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
Binary file added app/assets/fonts/Lato-Bold.ttf
Binary file not shown.
Binary file added app/assets/fonts/Lato-BoldItalic.ttf
Binary file not shown.
Binary file added app/assets/fonts/Lato-Italic.ttf
Binary file not shown.
Binary file added app/assets/fonts/Lato-Regular.ttf
Binary file not shown.
Empty file added app/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added app/assets/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion app/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
["@babel/plugin-transform-private-methods", { "loose": true }],
['@babel/plugin-transform-private-methods', {loose: true}],
[
'@babel/plugin-transform-runtime',
{
regenerator: true,
},
],
],
};
59 changes: 14 additions & 45 deletions app/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,7 @@
use_frameworks!
platform :ios, '14.0'

# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
'require.resolve(
"react-native/scripts/react_native_pods.rb",
{paths: [process.argv[1]]},
)', __dir__]).strip



platform :ios, '13.0'
prepare_react_native_project!


# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Expand All @@ -31,12 +10,8 @@ if linkage != nil
end

target 'ProofOfPassport' do

config = use_native_modules!

# Flags change depending on the env values.
flags = get_default_flags()

use_frameworks!
pod 'NFCPassportReader', git: 'https://github.com/0xturboblitz/NFCPassportReader.git', commit: '310ecb519655d9ed8b1afc5eb490b2f51a4d3595'
pod 'QKMRZScanner'
Expand All @@ -46,12 +21,7 @@ target 'ProofOfPassport' do
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
:hermes_enabled => false,
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
#:flipper_configuration => flipper_config,
:fabric_enabled => false,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
Expand All @@ -64,19 +34,18 @@ target 'ProofOfPassport' do
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
end
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']

# Excluir arquitecturas para evitar problemas con los simuladores
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
end
end
end

# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
# Add Flipper post_install block
react_native_post_install(installer)
# __apply_Xcode_12_5_M1_post_install_workaround(installer) # Remove or comment out this line
end
end
Loading