Skip to content

Commit

Permalink
Merge pull request #4 from Chisomo-Chiweza/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Tobi-Archademy authored Nov 29, 2022
2 parents 4f5b9ab + 3fd69cf commit 15a1c56
Show file tree
Hide file tree
Showing 48 changed files with 1,427 additions and 287 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
// Material Design
implementation 'com.google.android.material:material:1.7.0'
// Circle Image View
implementation 'de.hdodenhof:circleimageview:3.1.0'
// Init Font sizes
implementation 'com.intuit.sdp:sdp-android:1.1.0'
implementation 'com.intuit.ssp:ssp-android:1.1.0'
Expand Down
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
)
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

)
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,
)
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 }

}
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


}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class HomeFragment : Fragment() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

setupNavigation()
setupActions()

Expand All @@ -50,26 +49,28 @@ class HomeFragment : Fragment() {
}

private fun setupActions() {

binding.apply {
tasksInProgress.setOnClickListener {
val action = HomeFragmentDirections.actionHomeToTasksNavigation()

binding.tasksInProgress.setOnClickListener {
val action = HomeFragmentDirections.actionHomeFragmentToTasksNavigation()
findNavController().navigate(action)
}
chat.setOnClickListener {
val action = HomeFragmentDirections.actionHomeToMessages()

binding.myManagers.setOnClickListener {
val action = HomeFragmentDirections.actionHomeFragmentToMyManagers()
findNavController().navigate(action)
}
reports.setOnClickListener {
val action = HomeFragmentDirections.actionHomeToReportsNavigation()

binding.reports.setOnClickListener {
val action = HomeFragmentDirections.actionHomeFragmentToReportsNavigation()
findNavController().navigate(action)
}
certificates.setOnClickListener {
val action = HomeFragmentDirections.actionHomeToCertificates()
binding.certificates.setOnClickListener {
val action = HomeFragmentDirections.actionHomeFragmentToCertificates()
findNavController().navigate(action)
}
}

}
}

}
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
}

}

}

}
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
package com.peculiaruc.alc_mmsystem_mentor.ui.profile.screens
package com.peculiaruc.alc_mmsystem_mentor.ui.managers.screens

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.navigation.findNavController
import androidx.navigation.fragment.navArgs
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.NavigationUI
import androidx.navigation.ui.setupWithNavController
import com.peculiaruc.alc_mmsystem_mentor.databinding.FragmentBroadcastMessagesBinding
import com.peculiaruc.alc_mmsystem_mentor.databinding.FragmentProfileBinding
import com.peculiaruc.alc_mmsystem_mentor.data.repositories.ManagersRepository
import com.peculiaruc.alc_mmsystem_mentor.databinding.FragmentManagerProfileBinding
import com.peculiaruc.alc_mmsystem_mentor.databinding.FragmentManagersBinding
import kotlinx.android.synthetic.main.manager_item.*

class ProfileFragment : Fragment() {
class ManagerProfileFragment : Fragment() {

private val args: ManagerProfileFragmentArgs by navArgs()
private var _binding: FragmentManagerProfileBinding? = null
private val binding get() = _binding!!

private lateinit var binding: FragmentProfileBinding
private lateinit var appBarConfiguration: AppBarConfiguration

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = FragmentProfileBinding

val manager = ManagersRepository.getManager(args.name)

_binding = FragmentManagerProfileBinding
.inflate(layoutInflater, container, false)

if (manager != null) {
binding.apply {
manager_name.text = manager.managerName
manager_title.text = manager.managerTitle
memberSince.text = manager.memberSince
}
}

return binding.root
}

Expand All @@ -38,10 +56,7 @@ class ProfileFragment : Fragment() {

binding.toolbar.setupWithNavController(binding.toolbar.findNavController())
appBarConfiguration = AppBarConfiguration(binding.toolbar.findNavController().graph)
NavigationUI.setupWithNavController(
binding.bottomNavigation,
binding.bottomNavigation.findNavController()
)

}

}
Loading

0 comments on commit 15a1c56

Please sign in to comment.