-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodified.txt
435 lines (422 loc) · 15.8 KB
/
modified.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
diff --git a/app/src/main/java/kr/ac/kookmin/clouddrawing/CloudDrawingActivity.kt b/app/src/main/java/kr/ac/kookmin/clouddrawing/CloudDrawingActivity.kt
index e25b315..2d4abad 100644
--- a/app/src/main/java/kr/ac/kookmin/clouddrawing/CloudDrawingActivity.kt
+++ b/app/src/main/java/kr/ac/kookmin/clouddrawing/CloudDrawingActivity.kt
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.location.LocationManager
import android.net.Uri
import android.os.Bundle
+import android.util.Log
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.rememberLauncherForActivityResult
@@ -100,6 +101,9 @@ class CloudDrawingActivity : ComponentActivity() {
val lng = intent.getDoubleExtra("lng", 0.0)
val address : String = intent.getStringExtra("address") ?: ""
val road_address : String = intent.getStringExtra("road_address") ?: ""
+ val a : String = intent.getStringExtra("region") ?: ""
+ Log.e("Testing", "region : " + a)
+ val region = mutableStateOf(intent.getStringExtra("region") ?: "")
val locations = mutableStateOf(if(road_address == "") address else road_address)
val locationAlias = mutableStateOf("")
@@ -132,6 +136,7 @@ class CloudDrawingActivity : ComponentActivity() {
lng = round(lng),
address = locations.value,
addressAlias = locationAlias.value,
+ region = region.value,
comment = mainContent.value,
postTime = Timestamp(Date(date.selectedDateMillis!!))
)
diff --git a/app/src/main/java/kr/ac/kookmin/clouddrawing/CloudListActivity.kt b/app/src/main/java/kr/ac/kookmin/clouddrawing/CloudListActivity.kt
index f35de7b..3906fbc 100644
--- a/app/src/main/java/kr/ac/kookmin/clouddrawing/CloudListActivity.kt
+++ b/app/src/main/java/kr/ac/kookmin/clouddrawing/CloudListActivity.kt
@@ -1,12 +1,15 @@
package kr.ac.kookmin.clouddrawing
import android.os.Bundle
+import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
+import androidx.compose.animation.Crossfade
import androidx.compose.foundation.Image
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.background
import androidx.compose.foundation.border
+import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -24,9 +27,14 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Divider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
@@ -42,12 +50,31 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import io.woong.compose.grid.SimpleGridCells
import io.woong.compose.grid.VerticalGrid
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.async
+import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.withContext
import kr.ac.kookmin.clouddrawing.components.LeftCloseBtn
+import kr.ac.kookmin.clouddrawing.dto.Post
+import kr.ac.kookmin.clouddrawing.dto.User
+import java.text.SimpleDateFormat
+import java.util.Date
class CloudListActivity : ComponentActivity() {
+
+ private var allPost : List<Post> = listOf()
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
+ runBlocking {
+ allPost = Post.getPostByUID(User.getCurrentUser()?.uid).toMutableList()
+ Log.e("Testing", "vandvandjv : ${allPost}")
+ }
+
setContent {
val verticalScroll = rememberScrollState()
val today by remember { mutableStateOf(0) }
@@ -57,7 +84,8 @@ class CloudListActivity : ComponentActivity() {
CloudList(
verticalScroll = verticalScroll,
leftCloseBtn = { finish() },
- today = today, month = month, allOf = allOf
+ today = today, month = month, allOf = allOf,
+ postList = allPost
)
}
}
@@ -68,7 +96,8 @@ class CloudListActivity : ComponentActivity() {
fun CloudList(
leftCloseBtn: () -> Unit = {},
verticalScroll: ScrollState = rememberScrollState(),
- today: Int = 0, month: Int = 0, allOf: Int = 0
+ today: Int = 0, month: Int = 0, allOf: Int = 0,
+ postList : List<Post> = listOf()
) {
Column(
modifier = Modifier
@@ -151,12 +180,16 @@ fun CloudList(
Spacer(Modifier.height(10.dp))
}
Spacer(Modifier.defaultMinSize(minHeight = 20.dp))
- ClContentBox()
+ ClContentBox(postList)
}
}
@Preview
@Composable
-fun ClContentBox() {
+fun ClContentBox(
+ postList : List<Post> = listOf()
+) {
+ var locNum by remember { mutableStateOf("전체") }
+
Column(
modifier = Modifier
.padding(start = 31.dp, end = 31.dp, bottom = 10.dp)
@@ -193,7 +226,10 @@ fun ClContentBox() {
Text(
text = location,
modifier = Modifier
- .padding(top = 10.dp),
+ .padding(top = 10.dp)
+ .clickable {
+ locNum = location
+ },
style = TextStyle(
fontSize = 13.sp,
fontFamily = FontFamily(Font(R.font.inter)),
@@ -204,48 +240,123 @@ fun ClContentBox() {
)
}
}
- // 세로선 추가
- Divider(
- modifier = Modifier
- .fillMaxHeight()
- .padding(top = 5.dp, bottom = 15.dp)
- .width(1.dp),
- color = Color(0xFFC9C9C9),
- thickness = 1.dp
- )
+ Crossfade(targetState = locNum) { location ->
- //card 자리
+ Divider(
+ modifier = Modifier
+ .fillMaxHeight()
+ .padding(top = 5.dp, bottom = 15.dp)
+ .width(1.dp),
+ color = Color(0xFFC9C9C9),
+ thickness = 1.dp
+ )
- //
- // 첫 번째 카드
- VerticalGrid(
- columns = SimpleGridCells.Fixed(2),
- modifier = Modifier
- .weight(1f)
- .padding(start = 20.dp),
- horizontalArrangement = Arrangement.spacedBy(20.dp),
- verticalArrangement = Arrangement.spacedBy(20.dp)
- ) {
- CLContentCard()
- CLContentCard()
- CLContentCard()
- CLContentCard()
+ VerticalGrid(
+ columns = SimpleGridCells.Fixed(2),
+ modifier = Modifier
+ .weight(1f)
+ .padding(start = 20.dp),
+ horizontalArrangement = Arrangement.spacedBy(20.dp),
+ verticalArrangement = Arrangement.spacedBy(20.dp)
+ ) {
+ run breaker@{
+ if (location == locations[0]) {
+ postList.forEach {
+ CLContentCard(it)
+ }
+ return@breaker
+ }
+
+ locations.forEach {
+ if (location == it) {
+ postList.forEach {
+ if (location == it.region) {
+ CLContentCard(it)
+ }
+ }
+ return@breaker
+ }
+ }
+ }
+ }
}
}
-
}
}
-
-
-
-
-
-
-
+ //card 자리
+ //
+ // 첫 번째 카드
+// VerticalGrid(
+// columns = SimpleGridCells.Fixed(2),
+// modifier = Modifier
+// .weight(1f)
+// .padding(start = 20.dp),
+// horizontalArrangement = Arrangement.spacedBy(20.dp),
+// verticalArrangement = Arrangement.spacedBy(20.dp)
+// ) {
+//
+// }
+// /*
+// Crossfade(targetState = locNum) { location ->
+// run breaker@{
+// if (location == locations[0]) {
+// postList.forEach {
+// CLContentCard(it)
+// }
+// return@breaker
+// }
+//
+// locations.forEach {
+// if (location == it) {
+// postList.forEach {
+// if (location == it.region) {
+// CLContentCard(it)
+// }
+// }
+// return@breaker
+// }
+// }
+// }
+// }
+// Crossfade(targetState = locNum) { location ->
+// VerticalGrid(
+// columns = SimpleGridCells.Fixed(2),
+// modifier = Modifier
+// .weight(1f)
+// .padding(start = 20.dp),
+// horizontalArrangement = Arrangement.spacedBy(20.dp),
+// verticalArrangement = Arrangement.spacedBy(20.dp)
+// ) {
+// run breaker@ {
+// if (location == locations[0]) {
+// postList.forEach {
+// CLContentCard(it)
+// }
+// return@breaker
+// }
+//
+// locations.forEach {
+// if (location == it) {
+// postList.forEach {
+// if (location == it.region) {
+// CLContentCard(it)
+// }
+// }
+// return@breaker
+// }
+// }
+// }
+// }
+// */
+// }
+//
+//
@Preview
@Composable
-fun CLContentCard(){
+fun CLContentCard(
+ post: Post? = null
+) {
Column(
modifier = Modifier
.width(100.dp)
@@ -284,7 +395,7 @@ fun CLContentCard(){
)
Spacer(Modifier.width(4.dp))
Text(
- text = "TB_Location",
+ text = post?.address ?: "TB_Location",
style = TextStyle(
fontSize = 12.sp,
fontFamily = FontFamily(Font(R.font.inter)),
@@ -304,7 +415,7 @@ fun CLContentCard(){
horizontalArrangement = Arrangement.Center
) {
Text(
- text = "TB_Title",
+ text = post?.title ?: "TB_Title",
style = TextStyle(
fontSize = 10.sp,
fontFamily = FontFamily(Font(R.font.inter)),
@@ -319,11 +430,13 @@ fun CLContentCard(){
Row(
modifier = Modifier
.fillMaxWidth(1f)
- .padding(end = 9.dp, bottom =5.dp),
+ .padding(end = 9.dp, bottom = 5.dp),
horizontalArrangement = Arrangement.End
) {
Text(
- text = "2023.11.09",
+ text = SimpleDateFormat("yyyy-MM-dd").format(
+ post?.postTime?.toDate() ?: Date()
+ ),
style = TextStyle(
fontSize = 7.sp,
fontFamily = FontFamily(Font(R.font.inter)),
@@ -333,8 +446,5 @@ fun CLContentCard(){
)
)
}
-
-
-
}
}
\ No newline at end of file
diff --git a/app/src/main/java/kr/ac/kookmin/clouddrawing/MainActivity.kt b/app/src/main/java/kr/ac/kookmin/clouddrawing/MainActivity.kt
index 978112a..79e2ec2 100644
--- a/app/src/main/java/kr/ac/kookmin/clouddrawing/MainActivity.kt
+++ b/app/src/main/java/kr/ac/kookmin/clouddrawing/MainActivity.kt
@@ -111,6 +111,7 @@ class MainActivity : AppCompatActivity() {
private var lng: Double = 127.108621
private var address: String? = ""
private var road_address: String? = ""
+ private var region_1depth_name: String? = ""
private lateinit var API_KEY: String
private var user: User? = null
@@ -119,6 +120,7 @@ class MainActivity : AppCompatActivity() {
private var mutatePostList = mutableListOf<Post>()
private var postListOfRecents = mutableStateOf(listOf<Post>())
+ private var testing = mutableListOf<Post>()
companion object {
private val LOCATION_PERMISSIONS = arrayOf(
@@ -189,6 +191,7 @@ class MainActivity : AppCompatActivity() {
}
}
}
+
}
override fun getPosition(): LatLng {
@@ -297,6 +300,12 @@ class MainActivity : AppCompatActivity() {
result?.documents?.get(0)?.address?.address_name
[email protected]_address =
result?.documents?.get(0)?.road_address?.address_name
+ [email protected]_1depth_name =
+ if (result?.documents?.get(0)?.road_address == null) {
+ result?.documents?.get(0)?.address?.region_1depth_name
+ } else {
+ result?.documents?.get(0)?.road_address?.region_1depth_name
+ }
Log.d(TAG, "body : $result")
} else {
Log.d(TAG, "None")
@@ -306,6 +315,7 @@ class MainActivity : AppCompatActivity() {
Log.d(TAG, "address: ${[email protected]}")
intent.putExtra("address", [email protected])
intent.putExtra("road_address", [email protected]_address)
+ intent.putExtra("region", [email protected]_1depth_name)
intent.putExtra("lat", [email protected])
intent.putExtra("lng", [email protected])
startActivity(intent)
diff --git a/app/src/main/java/kr/ac/kookmin/clouddrawing/dto/Post.kt b/app/src/main/java/kr/ac/kookmin/clouddrawing/dto/Post.kt
index 5876bb5..0841629 100644
--- a/app/src/main/java/kr/ac/kookmin/clouddrawing/dto/Post.kt
+++ b/app/src/main/java/kr/ac/kookmin/clouddrawing/dto/Post.kt
@@ -15,6 +15,7 @@ data class Post(
var lng: Double? = 0.0,
var address: String? = "",
var addressAlias: String? = "",
+ var region: String? = "",
var comment: String? = "",
var image: MutableList<String> = mutableListOf(),
var writeTime: Timestamp? = Timestamp.now(),
@@ -22,11 +23,23 @@ data class Post(
) {
companion object {
private val post = FirebaseFirestore.getInstance().collection("post")
+
+ suspend fun getAllPost(): List<Post> {
+ var result = mutableListOf<Post?>()
+ val allPost = post.get().await()
+
+ allPost.forEach {
+ result.add(it.toObject())
+ }
+
+ return result.filterNotNull()
+ }
+
suspend fun getPostById(id: String): Post? {
return post.document(id).get().await().toObject()
}
- suspend fun getPostByUID(uid: String, limit: Long = 10L): List<Post> {
+ suspend fun getPostByUID(uid: String?, limit: Long = 10L): List<Post> {
val result = mutableListOf<Post?>()
val posts = post.whereEqualTo("uid", uid)