Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enzevalos_iphone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
enzevalos
enzevalos_iphone
Commits
9f4ac92c
Commit
9f4ac92c
authored
4 years ago
by
Aylin
Browse files
Options
Downloads
Patches
Plain Diff
Reversed file previews so that newer files are on the left where user can see them
parent
5b02137b
No related branches found
No related tags found
1 merge request
!83
Resolve "Integrate attachment functionality in new ComposeView"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
enzevalos_iphone/SwiftUI/Compose/AddAttachmentsView.swift
+17
-18
17 additions, 18 deletions
enzevalos_iphone/SwiftUI/Compose/AddAttachmentsView.swift
with
17 additions
and
18 deletions
enzevalos_iphone/SwiftUI/Compose/AddAttachmentsView.swift
+
17
−
18
View file @
9f4ac92c
...
...
@@ -21,15 +21,10 @@ struct AddAttachmentsView: View {
// properties to handle several sheet views (only one .sheet(...) is allowed)
@State
var
showSheet
=
false
@State
var
sheetState
=
SheetStates
.
none
{
willSet
{
showSheet
=
newValue
!=
.
none
}
}
@State
var
currentSheetState
:
SheetStates
?
/// SheetStates to controll several sheet views
enum
SheetStates
{
case
none
// default
case
imageImport
// user presses imageUploadButton
case
fullScreenFilePreview
// user taps on a file preview
}
...
...
@@ -37,10 +32,12 @@ struct AddAttachmentsView: View {
/// a func that returns the right sheet content according to the sheetState
@ViewBuilder
private
func
sheetContent
()
->
some
View
{
switch
sheetState
{
case
.
imageImport
:
// open the gallery and let user pick an image
switch
currentSheetState
{
case
.
imageImport
:
// open the gallery and let user pick an image
ImagePicker
(
image
:
self
.
$inputImage
)
case
.
fullScreenFilePreview
:
// open the attachment in 'fullScreenAttachment' fullscreen
case
.
fullScreenFilePreview
:
// open the attachment in 'fullScreenAttachment' fullscreen
if
let
attachment
=
fullScreenAttachment
{
// file name
Text
(
attachment
.
myName
)
...
...
@@ -58,14 +55,15 @@ struct AddAttachmentsView: View {
/// a func that returns the right onDismiss parameter according to the sheetState
private
func
sheetOnDismiss
()
{
switch
sheetState
{
case
.
imageImport
:
// TODO: currently no inputImage is imported even if user chose one
switch
currentSheetState
{
case
.
imageImport
:
// TODO: currently no inputImage is imported even if user chose one
guard
let
inputImage
=
inputImage
else
{
return
}
image
=
Image
(
uiImage
:
inputImage
)
self
.
s
heetState
=
.
none
self
.
currentS
heetState
=
nil
case
.
fullScreenFilePreview
:
self
.
showSheet
=
false
self
.
s
heetState
=
.
none
self
.
currentS
heetState
=
nil
self
.
fullScreenAttachment
=
nil
default
:
return
}
...
...
@@ -119,13 +117,13 @@ struct AddAttachmentsView: View {
// Error while loading file
print
(
"Error while importing file."
)
}
}
// end of fileImport
}
}
/// a view that contains the upload button for pictures
var
imageUploadButton
:
some
View
{
Button
{
self
.
s
heetState
=
.
imageImport
self
.
currentS
heetState
=
.
imageImport
showSheet
.
toggle
()
}
label
:
{
// try to imitate SF Symbol "doc.badge.plus"
...
...
@@ -148,11 +146,11 @@ struct AddAttachmentsView: View {
/// a view that contains several file previews together with their delete buttons
var
filePreviews
:
some
View
{
ForEach
(
model
.
attachments
,
id
:
\
.
self
.
myID
)
{
currentFile
in
ForEach
(
model
.
attachments
.
reversed
()
,
id
:
\
.
self
.
myID
)
{
currentFile
in
ZStack
{
// file preview using Quicklook
// shallDL has to be true here, because QuickLookView
then
download
s
// the file into the Documents Directory
// shallDL has to be true here, because QuickLookView
will
download
// the file into the Documents Directory
for us
// it then uses that DD file to create a preview of the content
QuickLookView
(
name
:
currentFile
.
myName
,
data
:
currentFile
.
myData
,
shallDL
:
true
)
.
padding
(
3
)
...
...
@@ -166,6 +164,7 @@ struct AddAttachmentsView: View {
// delete button in upper right corner
Button
{
// remove from attachments list and remove from Documents Directory
// to keep DD clean
if
let
deleteIndex
=
model
.
attachments
.
firstIndex
(
of
:
currentFile
)
{
model
.
attachments
[
deleteIndex
]
.
removeFileFromDocumentsDirectory
()
model
.
attachments
.
remove
(
at
:
deleteIndex
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment