Skip to content

Commit

Permalink
Merge pull request #88 from snuhcs-course/last-createMeetup
Browse files Browse the repository at this point in the history
Last create meetup
  • Loading branch information
sggithi authored Dec 7, 2023
2 parents aa55dce + c820509 commit 35bb7b7
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 79 deletions.
1 change: 1 addition & 0 deletions frontend/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />


<application
android:name=".MyApplication"
android:allowBackup="true"
Expand Down
81 changes: 43 additions & 38 deletions frontend/app/src/main/java/com/example/frontend/MeetupActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.material.Checkbox
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.DatePicker
Expand Down Expand Up @@ -75,9 +76,12 @@ import androidx.navigation.NavController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.example.frontend.data.defaultfriendIdsList
import com.example.frontend.model.MeetupModel
import com.example.frontend.model.UserModel
import com.example.frontend.model.UserWithLocationModel
import com.example.frontend.ui.component.MeetUpTopAppBar
import com.example.frontend.ui.component.MyTopAppBar
import com.example.frontend.ui.friend.FriendListUI
import com.example.frontend.usecase.CreateMeetUpUseCase

Expand Down Expand Up @@ -146,41 +150,43 @@ fun MeetupUI(navController: NavController, selectedFriends: MutableState<List<Lo
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(64.dp)
.background(Color(0xFFF3EDF7))
) {
Box {
Spacer(modifier = Modifier.height(15.dp))
Text(
text = "밋업 생성",
style = TextStyle(
fontSize = 22.sp,
fontWeight = FontWeight(400),
color = Color(0xFF000000),
textAlign = TextAlign.Center,
),
modifier = Modifier
.padding(top = 16.dp)
.width(400.dp)
.height(64.dp)
)
Button(
onClick = {
activity?.finish()
},

modifier = Modifier
.width(100.dp)
.height(50.dp)
.padding(start = 16.dp, top = 16.dp),
colors = ButtonDefaults.buttonColors(Purple80)
) {
Text(text = "취소")
}

// Box(
// modifier = Modifier
// .fillMaxWidth()
// .height(64.dp)
// .background(Color(0xFFF3EDF7))
// ) {
// Box {
// Spacer(modifier = Modifier.height(15.dp))
// Text(
// text = "밋업 생성",
// style = TextStyle(
// fontSize = 22.sp,
// fontWeight = FontWeight(400),
// color = Color(0xFF000000),
// textAlign = TextAlign.Center,
// ),
// modifier = Modifier
// .padding(top = 16.dp)
// .width(400.dp)
// .height(64.dp)
// )
// Button(
// onClick = {
// activity?.finish()
// },
//
// modifier = Modifier
// .width(100.dp)
// .height(50.dp)
// .padding(start = 16.dp, top = 16.dp),
// colors = ButtonDefaults.buttonColors(Purple80)
// ) {
// Text(text = "취소")
// }
MeetUpTopAppBar(
title = "밋업 생성",
actions = {
Button(
onClick = {
var meetup = MeetupModel(title, description, selectedFriends.value, meetAt.value, true, meetUpPlace.value)
Expand All @@ -193,15 +199,14 @@ fun MeetupUI(navController: NavController, selectedFriends: MutableState<List<Lo
modifier = Modifier
.width(100.dp)
.height(50.dp)
.align(Alignment.TopEnd)
.padding(end = 16.dp, top = 16.dp),
colors = ButtonDefaults.buttonColors(Purple80)
) {
Text(text = "완료")
}
}
)

}
Spacer(modifier = Modifier.height(15.dp))

OutlinedTextField(
Expand Down Expand Up @@ -432,7 +437,7 @@ fun MeetupUIPreview() {
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
// MeetupUI()

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.annotation.RequiresApi
Expand Down
30 changes: 3 additions & 27 deletions frontend/app/src/main/java/com/example/frontend/PlaceRecUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import com.example.frontend.model.PlaceResponse
import com.example.frontend.repository.UserContextRepository
import com.example.frontend.ui.component.LoadingIndicator
import com.example.frontend.ui.component.MapWithMarker
import com.example.frontend.ui.component.MyTopAppBar
import com.example.frontend.ui.theme.FrontendTheme
import com.example.frontend.usecase.ListPlaceUseCase
import com.google.android.gms.maps.model.LatLng
Expand Down Expand Up @@ -91,33 +92,8 @@ fun PlaceRecUI(
.background(color = Color(0xFFF3EDF7))
)
Column() {
Row(
modifier = Modifier
.height(54.dp)
.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
Icon(
imageVector = Icons.Outlined.KeyboardArrowLeft,
contentDescription = null,
modifier = Modifier
.size(46.dp)
.clickable {
navController.popBackStack()
}
)
Spacer(modifier = Modifier.width(8.dp))
Text(
modifier = Modifier,
text = "장소 추천",
style = TextStyle(
fontSize = 22.sp,
lineHeight = 28.sp,
fontWeight = FontWeight(400),
color = Color(0xFF1D1B20)
)
)
}

MyTopAppBar ("장소 추천")
Text(
text = userName?.let { "$userName 님, 이런 장소는 어때요?" } ?: "알 수 없는 사용자",
style = TextStyle(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.example.frontend.ui.component

import android.app.Activity
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.frontend.ui.theme.LightPurple
import com.example.frontend.ui.theme.Purple80

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MeetUpTopAppBar(
title: String,
actions: @Composable RowScope.() -> Unit = {},
) {
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
val context = LocalContext.current

CenterAlignedTopAppBar(
colors = TopAppBarDefaults.topAppBarColors(
containerColor = Color(0xFFF3EDF7),
titleContentColor = Color(0xFF000000)
),
title = {
Text(
title,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
},
navigationIcon = {
Button(
onClick = {
if (context is Activity) {
context.finish()
}
},
modifier = Modifier
.width(100.dp)
.height(50.dp)
.padding(start = 16.dp, top = 16.dp),
colors = ButtonDefaults.buttonColors(Purple80)
) {
Text(text = "취소")
}
},
scrollBehavior = scrollBehavior,
actions = actions,
)
}

@Preview
@Composable
private fun PreviewMyTopAppBar() {
MyTopAppBar(
title = "Meetup",
actions = {
IconButton(onClick = {}) {
Icon(
imageVector = Icons.Filled.Menu,
contentDescription = "Localized description"
)
}
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.app.Activity
import android.app.AlertDialog
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.widget.ImageView
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
Expand Down Expand Up @@ -52,6 +54,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
import com.example.frontend.MissionActivity
import com.example.frontend.R
import com.example.frontend.data.predefinedImages
import com.example.frontend.repository.UserContextRepository
import com.example.frontend.ui.component.CustomButton
Expand Down Expand Up @@ -107,28 +110,74 @@ fun UserInfoUI(onImageIdChanged: suspend (imageId: Int) -> Unit = {}) {
}
)
}
fun showImageSelectionDialog() {
val builder = AlertDialog.Builder(context)
val inflater = LayoutInflater.from(context)

val dialogView = inflater.inflate(R.layout.dialog_image, null)
builder.setView(dialogView)

fun showImageSelectionDialog() {
AlertDialog.Builder(context)
.setTitle("이미지 선택")
.setItems(
arrayOf("Gray Cat with Sunglass", "Yellow Cat with Sunglass", "Dog with Sunglass", "Hamster")
) { _, which ->
selectedPredefinedImage = predefinedImages[which]
val alertDialog = builder.create()

val imageGrayCat = dialogView.findViewById<ImageView>(R.id.imageGrayCat)
val imageYellowCat = dialogView.findViewById<ImageView>(R.id.imageYellowCat)
val imageHam = dialogView.findViewById<ImageView>(R.id.imageHam)
val imageDog = dialogView.findViewById<ImageView>(R.id.imageDog)

val images = listOf(imageGrayCat, imageYellowCat, imageHam, imageDog)
val predefinedImages = listOf(R.drawable.cat, R.drawable.cat_sunglass, R.drawable.dog_sunglass, R.drawable.hamster)

images.forEachIndexed { index, imageView ->
imageView.setImageResource(predefinedImages[index])
imageView.setOnClickListener {
selectedPredefinedImage = predefinedImages[index]
UserContextRepository.ofContext(context).saveSelectedPredefinedImage(selectedPredefinedImage)

coroutineScope.launch {
withContext(Dispatchers.IO) {
onImageIdChanged(which)
onImageIdChanged(index)
}
}

alertDialog.dismiss()
}
}

.show()
alertDialog.show()
}

// fun showImageSelectionDialog() {
// val builder = AlertDialog.Builder(context)
// val inflater = LayoutInflater.from(context)
//
// val dialogView = inflater.inflate(R.layout.dialog_image, null)
// builder.setView(dialogView)
//
// val alertDialog = builder.create()
//
// val imageGrayCat = dialogView.findViewById<ImageView>(R.id.imageGrayCat)
// val imageYellowCat = dialogView.findViewById<ImageView>(R.id.imageYellowCat)
// val imageHam = dialogView.findViewById<ImageView>(R.id.imageHam)
// val imageDog = dialogView.findViewById<ImageView>(R.id.imageDog)
//
// imageGrayCat.setOnClickListener {
// selectedPredefinedImage = predefinedImages[0] // Adjust as needed
// UserContextRepository.ofContext(context).saveSelectedPredefinedImage(selectedPredefinedImage)
//
// coroutineScope.launch {
// withContext(Dispatchers.IO) {
// onImageIdChanged(0) // Adjust as needed
// }
// }
//
// alertDialog.dismiss()
// }
//
//
// alertDialog.show()
// }


Box(
modifier = Modifier
.fillMaxSize()
Expand Down
Loading

0 comments on commit 35bb7b7

Please sign in to comment.