Skip to content

Commit

Permalink
:android: Redução no tamanho do APK de 10mb para 7mb
Browse files Browse the repository at this point in the history
:android: Proguard e Hermes habilitados
⚡ Melhorias de performance devido ao Hermes
🔥 Removido RefreshControl do Cardápio
🚚 Reescrita de diversos componentes
💄 Melhoria visual nos avisos de erro
🔖 Versão 1.03
  • Loading branch information
pitroldev committed Jun 29, 2020
1 parent 0b934cd commit 28a4eec
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 56 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="./resources/web_hi_res_512.png" width="150" alt="Logo do Cardápio Mobile UERJ" />
<h1>Cardápio Mobile UERJ</h1>
<a href="https://github.com/pitroldev/cardapio-mobile-uerj/releases">
<img src="https://img.shields.io/badge/version-1.02-green.svg" alt="Atual versão do Cardápio Mobile UERJ." />
<img src="https://img.shields.io/badge/version-1.03-green.svg" alt="Atual versão do Cardápio Mobile UERJ." />
</a>
<a href="https://github.com/pitroldev/cardapio-mobile-uerj/blob/master/LICENSE.txt">
<img src="https://img.shields.io/badge/license-Apache-blue.svg" alt="Cardápio Mobile UERJ está sob a licença APACHE." />
Expand Down
9 changes: 5 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import com.android.build.OutputFile
*/

project.ext.react = [
enableHermes: false, // clean and rebuild if changing
enableHermes: true, // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"
Expand All @@ -96,7 +96,7 @@ def enableSeparateBuildPerCPUArchitecture = true
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
def enableProguardInReleaseBuilds = true

/**
* The preferred build flavor of JavaScriptCore.
Expand Down Expand Up @@ -132,8 +132,8 @@ android {
applicationId "com.cardapiomobileuerj"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 3
versionName "1.02"
versionCode 4
versionName "1.03"
project.ext.set("archivesBaseName", "cardapio-mobile-uerj-" + defaultConfig.versionName);
}
splits {
Expand Down Expand Up @@ -169,6 +169,7 @@ android {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
minifyEnabled enableProguardInReleaseBuilds
shrinkResources enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
Expand Down
3 changes: 3 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:
-keep class com.facebook.hermes.unicode.** { *; }
-keep class com.facebook.jni.** { *; }
-keep public class com.horcrux.svg.** {*;}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cardapioMobileUerj",
"version": "1.0.0",
"version": "1.03",
"author": "Petro Cardoso",
"license": "Apache",
"private": true,
Expand Down
15 changes: 10 additions & 5 deletions src/components/Errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ const Title = styled.Text`
const Column = styled.View`
flex: 1;
padding: 2%;
margin-top: ${props => (props.margin ? props.margin : 0)}%;
align-items: center;
align-self: center;
justify-content: flex-end;
`;

const Refresh = styled.TouchableOpacity`
flex: 1;
background-color: #016ba5;
margin-top: 50%;
`;

const Text = styled.Text`
font-size: ${Responsive(14)}px;
font-weight: bold;
Expand Down Expand Up @@ -52,10 +57,10 @@ export const ParseErrorHeader = () => (
</Column>
);

export const NetworkErrorView = () => (
<Column margin={25}>
export const NetworkErrorView = props => (
<Refresh onPress={() => props.getCardapio()}>
<Icon name={'warning'} size={Responsive(60)} color={'#fff'} margin={10} />
<Title>Ops... Ocorreu um erro :(</Title>
<Title>{'\n'}Sem conexão disponível.</Title>
</Column>
</Refresh>
);
3 changes: 2 additions & 1 deletion src/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ AccessibilityInfo.isScreenReaderEnabled().then(res => {
AccessibilityIsOn = res;
});

const FooterView = Animated.createAnimatedComponent(FooterV);

const Footer = props => {
const FooterView = Animated.createAnimatedComponent(FooterV);
return (
<FooterView
style={[
Expand Down
33 changes: 14 additions & 19 deletions src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,30 @@ export const Loading = styled.ActivityIndicator`
margin: 10%;
`;

const Background = styled.View`
justify-content: center;
height: 200%;
width: 100%;
position: absolute;
z-index: 1;
`;

const HeaderV = styled.View`
background-color: #0080c6;
height: 110%;
top: -100%;
height: 210%;
top: -200%;
width: 100%;
position: absolute;
align-items: center;
justify-content: flex-end;
border-bottom-left-radius: 40px;
border-bottom-right-radius: 40px;
z-index: 1;
elevation: 6;
elevation: 12;
`;

const RowAbsolute = styled.View`
background-color: rgba(255, 255, 255, 0.25);
flex-direction: row;
align-self: center;
position: absolute;
top: 5%;
align-self: center;
justify-content: center;
padding: 1%;
bottom: 12%;
border-radius: 40px;
elevation: 12;
`;

const Icon = styled(EntypoIcon)`
Expand Down Expand Up @@ -67,7 +65,7 @@ const Header = props => {
useEffect(() => {}, [props.offline, props.parseError]);

return (
<Background pointerEvents={'none'}>
<>
<HeaderView
style={[
{
Expand All @@ -76,10 +74,7 @@ const Header = props => {
]}>
{props.loading && <Loading size={Responsive(60)} color="#fff" />}
{props.parseError ? (
<ParseErrorHeader
getCardapio={props.getCardapio}
refreshing={props.loading}
/>
<ParseErrorHeader />
) : (
<Title
accessible={true}
Expand All @@ -102,7 +97,7 @@ const Header = props => {
<Text>Você está offline</Text>
</RowAbsolute>
)}
</Background>
</>
);
};

Expand Down
1 change: 1 addition & 0 deletions src/components/carousel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from 'react';
import { Animated } from 'react-native';
import Carousel from 'react-native-snap-carousel';
import {
Container,
Expand Down
34 changes: 17 additions & 17 deletions src/pages/Main/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { RefreshControl, StatusBar, Animated } from 'react-native';
import { StatusBar, Animated } from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
const cheerio = require('react-native-cheerio');
import { RUapi } from '../../services/axios';
Expand All @@ -12,9 +12,8 @@ import About from '../../components/About';
import { ParseErrorView, NetworkErrorView } from '../../components/Errors';
import Header from '../../components/Header';

import { Refresh, Loading, Background } from './styles';

const CardapioView = Animated.createAnimatedComponent(Refresh);
import { Loading, Background, View } from './styles';
const CardapioView = Animated.createAnimatedComponent(View);

export default class Main extends Component {
state = {
Expand Down Expand Up @@ -235,39 +234,40 @@ export default class Main extends Component {
return (
<Background>
<StatusBar backgroundColor={this.state.about ? '#eaeaea' : '#0080c6'} />
<About
visible={this.state.about}
setState={state => this.setState(state)}
/>
<Header
parseError={this.state.parseError}
offline={this.state.offline}
getCardapio={this.getCardapio}
loading={this.state.loading}
height={this.state.headerHeight}
/>
<About
visible={this.state.about}
setState={state => this.setState(state)}
/>

<CardapioView
accessible={false}
importantForAccessibility={'no'}
refreshControl={
<RefreshControl
refreshing={false}
onRefresh={() => this.getCardapio()}
/>
}
style={[
{
translateY: this.state.menuHeight,
},
]}>
{this.state.networkError && !this.state.offine ? (
<NetworkErrorView />
<NetworkErrorView
getCardapio={this.getCardapio}
menuHeight={this.state.menuHeight}
/>
) : this.state.parseError ? (
<ParseErrorView />
) : this.state.loading ? (
<Loading size={Responsive(60)} color="#fff" />
) : (
<CarouselView data={this.state.data} />
<CarouselView
data={this.state.data}
getCardapio={this.getCardapio}
menuHeight={this.state.menuHeight}
/>
)}
</CardapioView>
<Footer
Expand Down
16 changes: 8 additions & 8 deletions src/pages/Main/styles.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import styled from 'styled-components/native';

export const Refresh = styled.ScrollView`
background-color: #016ba5;
border-bottom-left-radius: 40px;
border-bottom-right-radius: 40px;
elevation: 6;
z-index: 2;
`;

export const Loading = styled.ActivityIndicator`
margin-top: 50%;
`;
Expand All @@ -16,3 +8,11 @@ export const Background = styled.View`
flex: 1;
background-color: #01507c;
`;

export const View = styled.ScrollView`
flex: 1;
border-bottom-left-radius: 40px;
border-bottom-right-radius: 40px;
background-color: #016ba5;
elevation: 6;
`;

0 comments on commit 28a4eec

Please sign in to comment.