Add drawer menu with flat structure, unified panel styling, Room/SQLCipher setup
This commit is contained in:
parent
21505aae75
commit
7eadec669c
45 changed files with 1378 additions and 18 deletions
45
app/src/main/java/com/mistral/chat/ui/SessionsAdapter.kt
Normal file
45
app/src/main/java/com/mistral/chat/ui/SessionsAdapter.kt
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package com.mistral.chat.ui
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mistral.chat.R
|
||||
import com.mistral.chat.data.Session
|
||||
|
||||
class SessionsAdapter(
|
||||
private val sessions: List<Session>,
|
||||
private val getCurrentSessionId: () -> Long?,
|
||||
private val onSessionClick: (Session) -> Unit,
|
||||
private val onSessionLongClick: (Session) -> Unit
|
||||
) : RecyclerView.Adapter<SessionsAdapter.ViewHolder>() {
|
||||
|
||||
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val title: TextView = view.findViewById(R.id.sessionTitle)
|
||||
val checkmark: ImageView = view.findViewById(R.id.sessionCheckmark)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.item_session, parent, false)
|
||||
return ViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val session = sessions[position]
|
||||
val currentId = getCurrentSessionId()
|
||||
holder.title.text = session.title
|
||||
holder.title.alpha = if (session.id == currentId) 1.0f else 0.7f
|
||||
holder.checkmark.visibility = if (session.id == currentId) View.VISIBLE else View.GONE
|
||||
|
||||
holder.itemView.setOnClickListener { onSessionClick(session) }
|
||||
holder.itemView.setOnLongClickListener {
|
||||
onSessionLongClick(session)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = sessions.size
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue