Skip to content

Commit

Permalink
adding notification page
Browse files Browse the repository at this point in the history
  • Loading branch information
Moirand committed Aug 28, 2024
1 parent eb8a869 commit 2817c64
Show file tree
Hide file tree
Showing 27 changed files with 409 additions and 62 deletions.
22 changes: 22 additions & 0 deletions .idea/other.xml

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

9 changes: 9 additions & 0 deletions common/src/main/res/drawable/ic_refresh.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="22dp"
android:viewportWidth="16"
android:viewportHeight="22">
<path
android:pathData="M1.1,15.05C0.733,14.417 0.458,13.767 0.275,13.1C0.092,12.433 0,11.75 0,11.05C0,8.817 0.775,6.917 2.325,5.35C3.875,3.783 5.767,3 8,3H8.175L6.575,1.4L7.975,0L11.975,4L7.975,8L6.575,6.6L8.175,5H8C6.333,5 4.917,5.588 3.75,6.762C2.583,7.938 2,9.367 2,11.05C2,11.483 2.05,11.908 2.15,12.325C2.25,12.742 2.4,13.15 2.6,13.55L1.1,15.05ZM8.025,22L4.025,18L8.025,14L9.425,15.4L7.825,17H8C9.667,17 11.083,16.413 12.25,15.238C13.417,14.063 14,12.633 14,10.95C14,10.517 13.95,10.092 13.85,9.675C13.75,9.258 13.6,8.85 13.4,8.45L14.9,6.95C15.267,7.583 15.542,8.233 15.725,8.9C15.908,9.567 16,10.25 16,10.95C16,13.183 15.225,15.083 13.675,16.65C12.125,18.217 10.233,19 8,19H7.825L9.425,20.6L8.025,22Z"
android:fillColor="#1C1B1F"/>
</vector>
11 changes: 0 additions & 11 deletions common/src/main/res/values-v28/style.xml

This file was deleted.

6 changes: 0 additions & 6 deletions common/src/main/res/values/style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<item name="android:fontFamily">@font/calibrib</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">32sp</item>
<!-- <item name="android:lineHeight">40dp</item>-->
<!-- <item name="android:letterSpacing">-0.75</item>-->
</style>

<style name="circleImageView" parent="">
Expand All @@ -18,16 +16,12 @@
<item name="android:fontFamily">@font/calibri</item>
<item name="android:textStyle">normal</item>
<item name="android:textSize">16sp</item>
<!-- <item name="android:lineHeight">24dp</item>-->
<!-- <item name="android:letterSpacing">+0.15</item>-->
</style>

<style name="LightText">
<item name="android:fontFamily">@font/calibrilight</item>
<item name="android:textStyle">normal</item>
<item name="android:textSize">14sp</item>
<item name="android:lineHeight">23dp</item>
<item name="android:letterSpacing">0</item>
</style>

</resources>
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
package com.synrgy7team4.data.feature_dashboard

import com.synrgy7team4.data.feature_dashboard.datasource.remote.response.BalanceGetResponse
import com.synrgy7team4.data.feature_dashboard.datasource.remote.response.NotificationGetResponseItem
import com.synrgy7team4.domain.feature_dashboard.model.response.BalanceGetResponseDomain
import com.synrgy7team4.domain.feature_dashboard.model.response.NotificationGetResponseItemDomain

object FileUtils {
fun BalanceGetResponse.toBalanceGetResponseDomain(): BalanceGetResponseDomain =
fun BalanceGetResponse.toDomain(): BalanceGetResponseDomain =
BalanceGetResponseDomain(
success = success,
message = message,
data = data
)

fun NotificationGetResponseItem.toDomain(): NotificationGetResponseItemDomain =
NotificationGetResponseItemDomain(
id = id,
title = title,
body = body,
sentAt = sentAt,
read = read
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.synrgy7team4.data.feature_dashboard.datasource.remote

import com.synrgy7team4.data.feature_dashboard.datasource.remote.response.BalanceGetResponse
import com.synrgy7team4.data.feature_dashboard.datasource.remote.response.NotificationGetResponseItem

interface BalanceRemoteDatasource {
interface DashboardRemoteDatasource {
suspend fun getBalance(jwtToken: String, accountNumber: String): BalanceGetResponse
suspend fun getNotification(jwtToken: String): List<NotificationGetResponseItem>
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.synrgy7team4.data.feature_dashboard.datasource.remote

import com.synrgy7team4.data.feature_dashboard.datasource.remote.response.BalanceGetResponse
import com.synrgy7team4.data.feature_dashboard.datasource.remote.response.NotificationGetResponseItem
import com.synrgy7team4.data.feature_dashboard.datasource.remote.retrofit.ApiService
import com.synrgy7team4.domain.feature_dashboard.usecase.HttpExceptionUseCase
import retrofit2.HttpException

class ImplementBalanceRemoteDatasource(
class ImplementDashboardRemoteDatasource(
private val apiService: ApiService
): BalanceRemoteDatasource {
): DashboardRemoteDatasource {
override suspend fun getBalance(jwtToken: String, accountNumber: String): BalanceGetResponse =
try {
apiService.getBalance(jwtToken, accountNumber)
Expand All @@ -19,4 +20,16 @@ class ImplementBalanceRemoteDatasource(
throw HttpExceptionUseCase(e)
}
}

override suspend fun getNotification(jwtToken: String): List<NotificationGetResponseItem> =
try {
apiService.getNotification(jwtToken)
} catch (e: HttpException) {
val json = e.response()?.code()
if (json == 403) {
throw HttpExceptionUseCase(e, "403 Forbidden")
} else {
throw HttpExceptionUseCase(e)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.synrgy7team4.data.feature_dashboard.datasource.remote.response

import com.google.gson.annotations.SerializedName

data class NotificationGetResponseItem(
@field:SerializedName("id")
val id: String? = null,

@field:SerializedName("title")
val title: String? = null,

@field:SerializedName("body")
val body: String? = null,

@field:SerializedName("sentAt")
val sentAt: String? = null,

@field:SerializedName("read")
val read: Boolean
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.synrgy7team4.data.feature_dashboard.datasource.remote.retrofit

import com.synrgy7team4.data.feature_dashboard.datasource.remote.response.BalanceGetResponse
import com.synrgy7team4.data.feature_dashboard.datasource.remote.response.NotificationGetResponseItem
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Query
Expand All @@ -11,4 +12,9 @@ interface ApiService {
@Header("Authorization") jwtToken: String,
@Query("accountNumber") accountNumber: String
): BalanceGetResponse

@GET("notification/")
suspend fun getNotification(
@Header("Authorization") jwtToken: String
): List<NotificationGetResponseItem>
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.synrgy7team4.data.feature_dashboard.repository

import com.synrgy7team4.data.feature_dashboard.FileUtils.toDomain
import com.synrgy7team4.data.feature_dashboard.datasource.remote.DashboardRemoteDatasource
import com.synrgy7team4.domain.feature_dashboard.model.response.BalanceGetResponseDomain
import com.synrgy7team4.domain.feature_dashboard.model.response.NotificationGetResponseItemDomain
import com.synrgy7team4.domain.feature_dashboard.repository.DashboardRepository

class ImplementDashboardRepository(
private val dashboardRemoteSource: DashboardRemoteDatasource
) : DashboardRepository {
override suspend fun getBalance(jwtToken: String, accountNumber: String): BalanceGetResponseDomain =
dashboardRemoteSource.getBalance(jwtToken, accountNumber).toDomain()

override suspend fun getNotification(jwtToken: String): List<NotificationGetResponseItemDomain> =
dashboardRemoteSource.getNotification(jwtToken).map { it.toDomain() }
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package com.synrgy7team4.di.feature_dashboard

import com.synrgy7team4.data.feature_dashboard.datasource.remote.BalanceRemoteDatasource
import com.synrgy7team4.data.feature_dashboard.datasource.remote.ImplementBalanceRemoteDatasource
import com.synrgy7team4.data.feature_dashboard.datasource.remote.DashboardRemoteDatasource
import com.synrgy7team4.data.feature_dashboard.datasource.remote.ImplementDashboardRemoteDatasource
import com.synrgy7team4.data.feature_dashboard.datasource.remote.retrofit.ApiConfig
import com.synrgy7team4.data.feature_dashboard.datasource.remote.retrofit.ApiService
import com.synrgy7team4.data.feature_dashboard.repository.ImplementBalanceRepository
import com.synrgy7team4.domain.feature_dashboard.repository.BalanceRepository
import com.synrgy7team4.domain.feature_dashboard.usecase.BalanceUseCase
import com.synrgy7team4.data.feature_dashboard.repository.ImplementDashboardRepository
import com.synrgy7team4.domain.feature_dashboard.repository.DashboardRepository
import com.synrgy7team4.domain.feature_dashboard.usecase.DashboardUseCase
import org.koin.dsl.module

val dashboardKoin = module {
single<BalanceUseCase> { BalanceUseCase(get())}
single<DashboardUseCase> { DashboardUseCase(get())}

single<BalanceRepository> { ImplementBalanceRepository(get()) }
single<BalanceRemoteDatasource> { ImplementBalanceRemoteDatasource(get()) }
single<DashboardRepository> { ImplementDashboardRepository(get()) }
single<DashboardRemoteDatasource> { ImplementDashboardRemoteDatasource(get()) }

single<ApiService> { ApiConfig.provideApiService(get()) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.synrgy7team4.domain.feature_dashboard.model.response

data class NotificationGetResponseItemDomain(
val id: String? = null,
val title: String? = null,
val body: String? = null,
val sentAt: String? = null,
val read: Boolean
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.synrgy7team4.domain.feature_dashboard.repository

import com.synrgy7team4.domain.feature_dashboard.model.response.BalanceGetResponseDomain
import com.synrgy7team4.domain.feature_dashboard.model.response.NotificationGetResponseItemDomain

interface BalanceRepository {
interface DashboardRepository {
suspend fun getBalance(jwtToken: String, accountNumber: String): BalanceGetResponseDomain
suspend fun getNotification(jwtToken: String): List<NotificationGetResponseItemDomain>
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.synrgy7team4.domain.feature_dashboard.usecase

import com.synrgy7team4.domain.feature_dashboard.repository.DashboardRepository

class DashboardUseCase(
private val dashboardRepository: DashboardRepository
) {
suspend fun getBalance(jwtToken: String, accountNumber: String) =
dashboardRepository.getBalance(jwtToken, accountNumber)

suspend fun getNotification(jwtToken: String) =
dashboardRepository.getNotification(jwtToken)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import com.synrgy7team4.common.NavigationHandler
import com.synrgy7team4.common.makeToast
import com.synrgy7team4.feature_dashboard.R
Expand Down Expand Up @@ -36,6 +37,10 @@ class AccountFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
viewModel.getUserData()

binding.linearlayNotifikasi.setOnClickListener {
findNavController().navigate(R.id.action_accountFragment_to_notificationFragment)
}

binding.linearlayKeluarAkun.setOnClickListener {
makeToast(requireContext(),"Anda berhasil keluar")
lifecycleScope.launch {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.synrgy7team4.feature_dashboard.ui.notificationScreen

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.synrgy7team4.domain.feature_dashboard.model.response.NotificationGetResponseItemDomain
import com.synrgy7team4.feature_dashboard.R
import com.synrgy7team4.feature_dashboard.databinding.NotificationItemListBinding
import java.text.SimpleDateFormat
import java.util.Locale

class NotificationAdapter(
private val notificationList: List<NotificationGetResponseItemDomain>
) : RecyclerView.Adapter<NotificationAdapter.ViewHolder>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder =
ViewHolder(
LayoutInflater.from(parent.context).inflate(R.layout.notification_item_list, parent, false)
)

override fun onBindViewHolder(holder: ViewHolder, position: Int) = holder.bind(notificationList[position])

override fun getItemCount(): Int = notificationList.size

inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val binding = NotificationItemListBinding.bind(itemView)

fun bind(item: NotificationGetResponseItemDomain) {
binding.tvJudulTransaksi.text = item.title
binding.tvDeskripsiTransaksi.text = item.body
binding.tvWaktuTransaksi.text = convertDateFormat(item.sentAt)
}
}

private fun convertDateFormat(dateString: String?): String {
val inputFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS", Locale.US)
val outputFormat = SimpleDateFormat("dd MMM yyyy, HH:mm:ss", Locale("in", "ID"))

val date = inputFormat.parse(dateString)
return outputFormat.format(date)
}
}
Loading

0 comments on commit 2817c64

Please sign in to comment.