-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Chisomo-Chiweza/develop
Develop
- Loading branch information
Showing
48 changed files
with
1,427 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/peculiaruc/alc_mmsystem_mentor/data/local/database/models/Chat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.peculiaruc.alc_mmsystem_mentor.data.local.database.models | ||
|
||
data class Chat( | ||
val chatOwner: String, | ||
val messages: List<Message>, | ||
val numberOfNewMessages: Int? = null | ||
) |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/peculiaruc/alc_mmsystem_mentor/data/local/database/models/Manager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.peculiaruc.alc_mmsystem_mentor.data.local.database.models | ||
|
||
data class Manager( | ||
|
||
val managerName: String, | ||
val managerTitle: String, | ||
val about: String, | ||
val address: String? = null, | ||
val memberSince: String, | ||
val technicalProficiency: String? = null, | ||
val tags: List<String>? = null, | ||
val github: String? = null, | ||
val linkedIn: String? = null, | ||
val instagram: String? = null, | ||
val twitter: String? = null, | ||
val website: String? = null | ||
|
||
) |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/peculiaruc/alc_mmsystem_mentor/data/local/database/models/Message.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.peculiaruc.alc_mmsystem_mentor.data.local.database.models | ||
|
||
data class Message( | ||
val messageId: Int, | ||
val messageOwner: String, | ||
val messageType: String, | ||
val messageBody: String, | ||
val timeSent: String, | ||
val isSeen: Boolean? = null, | ||
) |
38 changes: 38 additions & 0 deletions
38
app/src/main/java/com/peculiaruc/alc_mmsystem_mentor/data/repositories/ManagersRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.peculiaruc.alc_mmsystem_mentor.data.repositories | ||
|
||
import com.peculiaruc.alc_mmsystem_mentor.data.local.database.models.Manager | ||
|
||
object ManagersRepository { | ||
|
||
val allManagers: List<Manager> = mutableListOf( | ||
|
||
Manager( | ||
managerName = "Kenny Dabiri", | ||
managerTitle = "Mentor Manager", | ||
about = """ | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ||
Praesent dignissimpharetra metus, ut cursus purus efficitur et. | ||
Duis ac enim tellus. Phasellus eget tortor dapibus, laoreet mauris | ||
sed, dignissim lectus. Phasellus eget tortor dapibus, laoreet mauris | ||
sed, dignissim lectus. | ||
""".trimIndent(), | ||
memberSince = "Member since June 22 2021", | ||
), | ||
Manager( | ||
managerName = "Peculiar C Umeh", | ||
managerTitle = "Admin", | ||
about = """ | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ||
Praesent dignissimpharetra metus, ut cursus purus efficitur et. | ||
Duis ac enim tellus. Phasellus eget tortor dapibus, laoreet mauris | ||
sed, dignissim lectus. Phasellus eget tortor dapibus, laoreet mauris | ||
sed, dignissim lectus. | ||
""".trimIndent(), | ||
memberSince = "Member since July 4 2017", | ||
) | ||
|
||
) | ||
|
||
fun getManager(name: String) : Manager? = allManagers.find { manager -> manager.managerName == name } | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
app/src/main/java/com/peculiaruc/alc_mmsystem_mentor/data/repositories/MessagesRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.peculiaruc.alc_mmsystem_mentor.data.repositories | ||
|
||
import com.peculiaruc.alc_mmsystem_mentor.data.local.database.models.Chat | ||
import com.peculiaruc.alc_mmsystem_mentor.data.local.database.models.Message | ||
|
||
object MessagesRepository { | ||
|
||
val allChats = mutableListOf<Chat>( | ||
|
||
Chat( | ||
chatOwner = "Kenny Dabiri", | ||
messages = mutableListOf( | ||
Message( | ||
messageId = 1, | ||
messageOwner = "Aisha Phiri", | ||
messageType = "received", | ||
messageBody = "Hello Aisha. Trust you are well?", | ||
timeSent = "6:35pm" | ||
), | ||
Message( | ||
messageId = 2, | ||
messageOwner = "Aisha Phiri", | ||
messageType = "sent", | ||
messageBody = "Hie Kenny, yes I am well thanks", | ||
timeSent = "6:40pm", | ||
isSeen = true | ||
), | ||
Message( | ||
messageId = 1, | ||
messageOwner = "Aisha Phiri", | ||
messageType = "received", | ||
messageBody = "I wanted to follow up on the assignment I gave you. Have you done it?", | ||
timeSent = "6:42pm" | ||
), | ||
Message( | ||
messageId = 2, | ||
messageOwner = "Aisha Phiri", | ||
messageType = "sent", | ||
messageBody = "No I haven't. Was waiting for you to onboard me.", | ||
timeSent = "7:00pm", | ||
isSeen = false | ||
), | ||
) | ||
), | ||
|
||
) | ||
|
||
fun getChatMessages(name: String): List<Message>? { | ||
|
||
val chat = allChats.find { chat -> chat.chatOwner == name } | ||
return chat?.messages | ||
|
||
} | ||
|
||
fun getTestMessages(): List<Message> = allChats[1].messages | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
.../main/java/com/peculiaruc/alc_mmsystem_mentor/ui/managers/adapters/ManagersListAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.peculiaruc.alc_mmsystem_mentor.ui.managers.adapters | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.navigation.findNavController | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.peculiaruc.alc_mmsystem_mentor.data.local.database.models.Manager | ||
import com.peculiaruc.alc_mmsystem_mentor.databinding.ManagerItemBinding | ||
import com.peculiaruc.alc_mmsystem_mentor.ui.managers.screens.ManagersFragmentDirections | ||
|
||
class ManagersListAdapter(private val onManagerClicked: (Manager) -> Unit) : | ||
ListAdapter<Manager, ManagersListAdapter.ManagerViewHolder>(DiffCallBack) { | ||
|
||
class ManagerViewHolder(private var binding: ManagerItemBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun bind(manager: Manager) { | ||
binding.apply { | ||
managerName.text = manager.managerName | ||
managerTitle.text = manager.managerTitle | ||
messageManager.setOnClickListener { | ||
val action = | ||
ManagersFragmentDirections.actionMyManagersToChatFragment(manager.managerName) | ||
itemView.findNavController().navigate(action) | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ManagerViewHolder { | ||
return ManagerViewHolder( | ||
ManagerItemBinding.inflate( | ||
LayoutInflater.from(parent.context) | ||
) | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ManagerViewHolder, position: Int) { | ||
|
||
val current = getItem(position) | ||
|
||
holder.itemView.setOnClickListener { | ||
onManagerClicked(current) | ||
} | ||
holder.bind(current) | ||
} | ||
|
||
companion object { | ||
|
||
private val DiffCallBack = object : DiffUtil.ItemCallback<Manager>() { | ||
|
||
override fun areItemsTheSame(oldItem: Manager, newItem: Manager): Boolean { | ||
return oldItem === newItem | ||
} | ||
|
||
override fun areContentsTheSame(oldItem: Manager, newItem: Manager): Boolean { | ||
return oldItem.managerName == newItem.managerName | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.