Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
inovisao
modelo_react_native_app
Commits
7533200b
Commit
7533200b
authored
1 year ago
by
Gustavo da Silva Andrade
Browse files
Options
Download
Email Patches
Plain Diff
adicionando camada para salvar foto
parent
83be6e10
main
mariah
No related merge requests found
Pipeline
#95
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
6 deletions
+28
-6
src/screens/Home/index.tsx
src/screens/Home/index.tsx
+28
-6
No files found.
src/screens/Home/index.tsx
View file @
7533200b
import
React
from
"
react
"
;
import
{
StatusBar
}
from
'
expo-status-bar
'
;
import
{
useState
}
from
'
react
'
;
import
{
useState
,
useRef
}
from
'
react
'
;
import
{
StyleSheet
,
View
,
Text
}
from
"
react-native
"
;
import
{
Container
,
ImageContainer
,
FooterContainer
,
OptionsContainer
,
OptionsRow
}
from
"
./styles
"
;
import
ImageViewer
from
"
../../components/ImageViewer
"
;
...
...
@@ -9,11 +9,15 @@ import * as ImagePicker from 'expo-image-picker';
import
IconButton
from
'
../../components/IconButton
'
;
import
{
IconButtonContainer
}
from
"
../../components/IconButton/styles
"
;
import
CircleButton
from
"
../../components/CircleButton
"
;
import
*
as
MediaLibrary
from
'
expo-media-library
'
;
import
{
captureRef
}
from
'
react-native-view-shot
'
;
const
PlaceholderImage
=
require
(
'
../../../assets/images/background.png
'
);
export
function
Home
()
{
const
imageRef
=
useRef
<
View
>
(
null
);
const
onReset
=
()
=>
{
setShowAppOptions
(
false
);
};
...
...
@@ -23,9 +27,22 @@ export function Home() {
};
const
onSaveImageAsync
=
async
()
=>
{
// we will implement this later
};
try
{
const
localUri
=
await
captureRef
(
imageRef
,
{
height
:
440
,
quality
:
1
,
});
await
MediaLibrary
.
saveToLibraryAsync
(
localUri
);
if
(
localUri
)
{
alert
(
"
Saved!
"
);
}
}
catch
(
e
)
{
console
.
log
(
e
);
}
};
const
[
status
,
requestPermission
]
=
MediaLibrary
.
usePermissions
();
const
[
selectedImage
,
setSelectedImage
]
=
useState
<
string
|
null
>
(
null
);
const
[
showAppOptions
,
setShowAppOptions
]
=
useState
(
false
);
const
pickImageAsync
=
async
()
=>
{
...
...
@@ -41,12 +58,17 @@ export function Home() {
alert
(
'
Você não selecionou nenhuma foto.
'
);
}
};
if
(
status
===
null
)
{
requestPermission
();
}
return
(
<
Container
>
<
ImageContainer
>
<
ImageViewer
placeholderImageSource
=
{
PlaceholderImage
}
selectedImage
=
{
selectedImage
}
>
</
ImageViewer
>
<
View
ref
=
{
imageRef
}
collapsable
=
{
false
}
>
<
ImageViewer
placeholderImageSource
=
{
PlaceholderImage
}
selectedImage
=
{
selectedImage
}
>
</
ImageViewer
>
</
View
>
</
ImageContainer
>
{
showAppOptions
?
(
<
View
style
=
{
styles
.
optionsContainer
}
>
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment