Skip to content

Commit

Permalink
Merge pull request #13 from Nbti/feat-mpz7
Browse files Browse the repository at this point in the history
Feat mpz7
  • Loading branch information
2xHjin authored Jun 10, 2023
2 parents fe87589 + e87210b commit e1f5b89
Show file tree
Hide file tree
Showing 62 changed files with 2,156 additions and 17 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ android {
jvmTarget = '1.8'
}
buildFeatures {
dataBinding = true
viewBinding = true
}
}

Expand All @@ -47,14 +47,18 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

//ktx
implementation 'androidx.activity:activity-ktx:1.7.2'
implementation 'androidx.fragment:fragment-ktx:1.6.0'
implementation 'androidx.activity:activity-ktx:1.7.0'
implementation 'androidx.fragment:fragment-ktx:1.5.6'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
implementation 'androidx.security:security-crypto-ktx:1.1.0-alpha06'
implementation 'androidx.navigation:navigation-fragment-ktx:2.6.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.6.0'
implementation 'androidx.security:security-crypto-ktx:1.1.0-alpha05'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'

//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

implementation 'com.google.android.flexbox:flexbox:3.0.0'

implementation 'androidx.viewpager2:viewpager2:1.0.0'
}
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
android:supportsRtl="true"
android:theme="@style/Theme.IDear"
tools:targetApi="31">
<activity
android:name=".mypage.MyPageActivity"
android:exported="false" />
<activity
android:name=".write.WriteActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
Expand Down
112 changes: 111 additions & 1 deletion app/src/main/java/com/nbit/Idear/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,121 @@
package com.nbit.Idear

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.core.view.GravityCompat
import androidx.recyclerview.widget.LinearLayoutManager
import com.nbit.Idear.databinding.ActivityMainBinding
import com.nbit.Idear.databinding.MainIncludeDrawerBinding
import com.nbit.Idear.home.ProxyWriteAdapter
import com.nbit.Idear.home.ProxyWriteData
import com.nbit.Idear.home.WriteSubData
import com.nbit.Idear.mypage.MyPageActivity
import com.nbit.Idear.write.WriteActivity

// 메인 페이지
class MainActivity : AppCompatActivity() {
// ViewBinding Setting
lateinit var drawerBinding: MainIncludeDrawerBinding // 메뉴 Drawer
lateinit var mainBinding: ActivityMainBinding // 메인 페이지
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

// 메뉴 Drawer ViewBinding
drawerBinding = MainIncludeDrawerBinding.inflate(layoutInflater)
setContentView(drawerBinding.root)

// 메인 페이지 viewBinding
mainBinding = drawerBinding.includeMainActivity

// 메뉴 열기 버튼 누르면 열림
mainBinding.btnOpenMenu.setOnClickListener {
drawerBinding.mainDrawerLayout.openDrawer((GravityCompat.END))
}

// 마이페이지 메뉴 버튼 선택
drawerBinding.btnMenuMypage.setOnClickListener {
// 마이페이지 이동
val intent = Intent(this, MyPageActivity::class.java)
startActivity(intent)

// 메뉴 닫기
drawerBinding.mainDrawerLayout.closeDrawer((GravityCompat.END))
}

// 즐겨찾기 메뉴 버튼 선택
drawerBinding.btnMenuBookmark.setOnClickListener {
// 즐겨찾기 목록 이동

// 메뉴 닫기
drawerBinding.mainDrawerLayout.closeDrawer((GravityCompat.END))
}

// 환경설정 메뉴 버튼 선택
drawerBinding.btnMenuSetting.setOnClickListener {
// 환경설정 이동

// 메뉴 닫기
drawerBinding.mainDrawerLayout.closeDrawer((GravityCompat.END))
}

// 로그인/로그아웃 메뉴 버튼 선택
drawerBinding.btnMenuLoginLogout.setOnClickListener {
// 로그인/로그아웃 이동

// 메뉴 닫기
drawerBinding.mainDrawerLayout.closeDrawer((GravityCompat.END))
}


// mainBinding=ActivityMainBinding.inflate(layoutInflater)

val dataDataList:ArrayList<ProxyWriteData> = arrayListOf()

dataDataList.apply{
/* add(ProxyWriteData(2023,6,12,"친구에게 전하는 생일 편지",
"생일 축하해! 이 특별한 날을 기념하여 마음 가득한 축하의 말을 전하고 싶어요. " +
"너의 생일은 항상 특별한 순간이야. 너의 유쾌한 에너지와 친절한 마음으로 언제나 우리 주위를 환하게 " +
"비춰줘서 고마워! 정말...",null))
*/
add(ProxyWriteData(2023,6,12,"친구에게 전하는 생일 편지","생일 축하해! 이 특별한 날을 기념하여 마음 가득한 축하의 말을 전하고 싶어요. 너의 생일은 항상 특별한 순간이야. 너의 유쾌한 에너지와 친절한 마음으로 언제나 우리 주위를 환하게 비춰줘...",
arrayListOf(WriteSubData("너는 내게 있어서 특별한 존재야. 우리가 ..."),
WriteSubData("너는 내게 있어서 특별한 존재야. 우리가..."))))

/*
*/
add(ProxyWriteData(2023,6,12,"친구에게 전하는 생일 편지","생일 축하해! 이 특별한 날을 기념하여 마음 가득한 축하의 말을 전하고 싶어요. 너의 생일은 항상 특별한 순간이야. 너의 유쾌한 에너지와 친절한 마음으로 언제나 우리 주위를 환하게 비춰줘...",
arrayListOf(WriteSubData("너는 내게 있어서 특별한 존재야. 우리가..."),
WriteSubData("너는 내게 있어서 특별한 존재야. 우리가..."),
WriteSubData("너는 내게 있어서 특별한 존재야. 우리가..."))))

add(ProxyWriteData(2023,6,12,"친구에게 전하는 생일 축하",
"생일 축하해! 이 특별한 날을 기념하여 마음 가득한 축하의 말을 전하고 싶어요. " +
"너의 생일은 항상 특별한 순간이야. 너의 유쾌한 에너지와 친절한 마음으로 언제나 우리 주위를 환하게 " +
"비춰줘서...",null))

}

mainBinding.mainRecyclerView.layoutManager=LinearLayoutManager(this)
val adapter=ProxyWriteAdapter(dataDataList)
mainBinding.mainRecyclerView.adapter=adapter

mainBinding.fab.setOnClickListener {

val intent = Intent(this, WriteActivity::class.java)
startActivity(intent)
}

//val retrofit = Retrofit.Builder()
// .baseUrl("https://api.example.com/") // 서버의 baseUrl을 설정합니다.
// .addConverterFactory(GsonConverterFactory.create()) // JSON 데이터 변환을 위한 Gson 변환기를 추가합니다.
// .build()

// val apiService = retrofit.create(RetrofitInterface::class.java)
// val apiService = RetrofitInterface.create()


}
}
81 changes: 81 additions & 0 deletions app/src/main/java/com/nbit/Idear/home/ProxyWriteAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.nbit.Idear.home

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.nbit.Idear.R
import com.nbit.Idear.databinding.ItemWriteBinding

class ProxyWriteAdapter (private val dataList:ArrayList<ProxyWriteData>):
RecyclerView.Adapter<ProxyWriteAdapter.DataViewHolder>() {
inner class DataViewHolder(private val viewBinding: ItemWriteBinding) : RecyclerView.ViewHolder(viewBinding.root) {
// var chk=false;
fun bind(data: ProxyWriteData) {
viewBinding.yearText.text = data.year.toString()
viewBinding.monthText.text = data.month.toString()
viewBinding.dayText.text = data.day.toString()
viewBinding.titleText.text=data.title

viewBinding.mainContent.text = data.content


viewBinding.upBtn.setOnClickListener {
if (data.additionalContent!= null) {
if (!viewBinding.upBtn.isSelected) {
viewBinding.upBtn.setImageResource(R.drawable.downbtn)
viewBinding.subCardView.visibility=View.VISIBLE
viewBinding.recyclerView.visibility = View.VISIBLE


viewBinding.recyclerView.apply {
setHasFixedSize(true)
layoutManager = LinearLayoutManager(viewBinding.root.context)
adapter = SubAdapter(data.additionalContent)
}
viewBinding.upBtn.isSelected = true
} else {
viewBinding.upBtn.setImageResource(R.drawable.upbtn)
viewBinding.subCardView.visibility=View.GONE
viewBinding.recyclerView.visibility = View.GONE

viewBinding.upBtn.isSelected = false
}

}
else{
if (!viewBinding.upBtn.isSelected) {
viewBinding.subCardView.visibility=View.VISIBLE
viewBinding.upBtn.isSelected = true

}
else {
viewBinding.subCardView.visibility=View.GONE
viewBinding.upBtn.isSelected = false
}
}
}
}


}




override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProxyWriteAdapter.DataViewHolder {
val binding = ItemWriteBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return DataViewHolder(binding)
}

override fun onBindViewHolder(holder: DataViewHolder, position: Int) {
holder.bind(dataList[position])
}

override fun getItemCount(): Int {
return dataList.size
}


}
9 changes: 9 additions & 0 deletions app/src/main/java/com/nbit/Idear/home/ProxyWriteData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.nbit.Idear.home

data class ProxyWriteData(val year:Int,
val month:Int,
val day:Int,
val title:String,
val content:String,
val additionalContent:ArrayList<WriteSubData>?)
//val phoneNumArray:ArrayList<WriteSubData>)
34 changes: 34 additions & 0 deletions app/src/main/java/com/nbit/Idear/home/SubAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.nbit.Idear.home

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.nbit.Idear.databinding.ItemSubWriteBinding

class SubAdapter(private val dataList:ArrayList<WriteSubData>):
RecyclerView.Adapter<SubAdapter.DataViewHolder>(){
inner class DataViewHolder(private val viewBinding:ItemSubWriteBinding) :RecyclerView.ViewHolder(viewBinding.root){

fun bind(data:WriteSubData){
viewBinding.subContentText.text=data.subContent

viewBinding.cardView.setOnClickListener {

}
}
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubAdapter.DataViewHolder {
val viewBinding = ItemSubWriteBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return DataViewHolder(viewBinding)
}

override fun onBindViewHolder(holder: DataViewHolder, position: Int) {
holder.bind(dataList[position])
}

override fun getItemCount(): Int {
return dataList.size
}

}
3 changes: 3 additions & 0 deletions app/src/main/java/com/nbit/Idear/home/WriteSubData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.nbit.Idear.home

data class WriteSubData (val subContent:String)
25 changes: 25 additions & 0 deletions app/src/main/java/com/nbit/Idear/mypage/AddProfileFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.nbit.Idear.mypage

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.nbit.Idear.R
import com.nbit.Idear.databinding.FragmentAddProfileBinding


// 프로필 추가/수정
class AddProfileFragment : Fragment() {
// ViewBinding Setting
lateinit var binding: FragmentAddProfileBinding

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// ViewBinding Setting
binding = FragmentAddProfileBinding.inflate(layoutInflater)
return binding.root
}
}
20 changes: 20 additions & 0 deletions app/src/main/java/com/nbit/Idear/mypage/MyPageActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.nbit.Idear.mypage

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.nbit.Idear.R
import com.nbit.Idear.databinding.ActivityMyPageBinding

// 마이 페이지: 프로필 리스트
class MyPageActivity : AppCompatActivity() {
// ViewBinding Setting
lateinit var binding: ActivityMyPageBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// ViewBinding Setting
binding = ActivityMyPageBinding.inflate(layoutInflater)
setContentView(binding.root)
}
}
Loading

0 comments on commit e1f5b89

Please sign in to comment.