Skip to content

Commit

Permalink
❇️ 히스토리 상세화면 공유하기 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
JeonK1 committed Sep 21, 2024
1 parent c74576e commit ec5747a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import com.mashup.gabbangzip.sharedalbum.presentation.theme.SharedAlbumTheme
import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.GroupKeyword
import com.mashup.gabbangzip.sharedalbum.presentation.utils.shareBitmap

class HistoryDetailActivity : ComponentActivity() {
private val state by lazy { intent.getSerializableExtra(KEY_HISTORY) as HistoryDetailState? }
Expand All @@ -29,6 +30,7 @@ class HistoryDetailActivity : ComponentActivity() {
keyword = GroupKeyword.getKeyword(state.keyword),
item = state.history,
onClickBackButton = { finish() },
onClickShareButton = { bitmap -> shareBitmap(bitmap) },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail

import android.graphics.Bitmap
import android.graphics.Picture
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -13,31 +15,38 @@ import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.mashup.gabbangzip.sharedalbum.presentation.R
import com.mashup.gabbangzip.sharedalbum.presentation.theme.Gray0
import com.mashup.gabbangzip.sharedalbum.presentation.theme.PicTypography
import com.mashup.gabbangzip.sharedalbum.presentation.theme.SharedAlbumTheme
import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicBackButtonTopBar
import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicCroppedPhoto
import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicNormalButton
import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicPhotoCardFrame
import com.mashup.gabbangzip.sharedalbum.presentation.ui.common.PicTopBarTitleAlign
import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.groupdetail.model.HistoryItem
import com.mashup.gabbangzip.sharedalbum.presentation.ui.main.grouphome.model.CardBackImage
import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.GroupKeyword
import com.mashup.gabbangzip.sharedalbum.presentation.ui.model.PicPhotoFrame
import com.mashup.gabbangzip.sharedalbum.presentation.utils.ImmutableList
import com.mashup.gabbangzip.sharedalbum.presentation.utils.captureIntoCanvas
import com.mashup.gabbangzip.sharedalbum.presentation.utils.createBitmap

@Composable
fun HistoryDetailScreen(
groupName: String,
keyword: GroupKeyword,
item: HistoryItem,
onClickBackButton: () -> Unit,
onClickShareButton: (Bitmap) -> Unit,
) {
val picture = remember { Picture() }
Column(
modifier = Modifier
.fillMaxSize()
Expand All @@ -52,11 +61,28 @@ fun HistoryDetailScreen(
titleAlign = PicTopBarTitleAlign.LEFT,
backButtonClicked = onClickBackButton,
)
HistoryPhotoCard(
Box(
modifier = Modifier.weight(1f),
contentAlignment = Alignment.Center,
) {
HistoryPhotoCard(
modifier = Modifier
.wrapContentSize()
.captureIntoCanvas(picture),
keyword = keyword,
item = item,
)
}
PicNormalButton(
modifier = Modifier
.weight(1f),
keyword = keyword,
item = item,
.padding(bottom = 79.dp)
.align(Alignment.CenterHorizontally),
iconRes = R.drawable.ic_share,
isSingleClick = true,
onButtonClicked = {
val bitmap = picture.createBitmap()
onClickShareButton(bitmap)
},
)
}
}
Expand Down Expand Up @@ -155,6 +181,7 @@ private fun HistoryDetailScreenPreview() {
),
),
onClickBackButton = {},
onClickShareButton = {},
)
}
}

0 comments on commit ec5747a

Please sign in to comment.