Skip to content

Commit

Permalink
Enhancement - Product Feature UI/UX
Browse files Browse the repository at this point in the history
- Close #910
- Close #911
  • Loading branch information
niyajali committed Jun 13, 2024
1 parent 9a864f0 commit 968ae59
Show file tree
Hide file tree
Showing 160 changed files with 2,876 additions and 1,812 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/com/niyaj/poposroom/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package com.niyaj.poposroom
import android.Manifest
import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.SystemBarStyle
import androidx.activity.compose.setContent
Expand All @@ -37,6 +36,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.compose.LocalLifecycleOwner
Expand Down Expand Up @@ -120,6 +120,8 @@ class MainActivity : ComponentActivity() {
}
}

WindowCompat.setDecorFitsSystemWindows(window, false)

enableEdgeToEdge()

registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result ->
Expand Down Expand Up @@ -156,8 +158,6 @@ class MainActivity : ComponentActivity() {
)
val isLoggedIn by appState.isLoggedIn.collectAsStateWithLifecycle()

Log.d("isLoggedIn", "$isLoggedIn")

CompositionLocalProvider(LocalAnalyticsHelper provides analyticsHelper) {
PoposRoomTheme(
darkTheme = darkTheme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ fun PoposNavHost(
navController.navigate(AddEditAbsentScreenDestination(employeeId = it))
},
paymentRecipient = resultRecipient<AddEditPaymentScreenDestination, String>(),
absentRecipient = resultRecipient<AddEditAbsentScreenDestination, String>()
absentRecipient = resultRecipient<AddEditAbsentScreenDestination, String>(),
)
}

Expand All @@ -179,7 +179,7 @@ fun PoposNavHost(
onClickAddEmployee = {
navController.navigate(AddEditEmployeeScreenDestination())
},
resultBackNavigator = resultBackNavigator()
resultBackNavigator = resultBackNavigator(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object AbsentScreenTags {

const val ABSENT_TAG = "Absent-"

const val ABSENT_SETTINGS_NOTE ="Make Sure To Import Employee Before Importing Employee Absent Dates."
const val ABSENT_SETTINGS_NOTE = "Make Sure To Import Employee Before Importing Employee Absent Dates."

const val ABSENT_SETTINGS_TITLE = "Absent Settings"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object CategoryConstants {

const val EXPORT_CATEGORY_TITLE = "Export Categories"
const val EXPORT_CATEGORY_TITLE_NOTE = "Click here to export category to file."

const val EXPORT_CATEGORY_BTN_TEXT = "Export Categories"
const val EXPORT_CATEGORY_BTN = "Export Categories"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object PaymentScreenTags {

const val PAYMENT_SETTINGS_TITLE = "Payment Settings"

const val PAYMENT_SETTINGS_NOTE ="Make Sure To Import Employee Before Importing Employee Payments."
const val PAYMENT_SETTINGS_NOTE = "Make Sure To Import Employee Before Importing Employee Payments."

const val IMPORT_PAYMENT_TITLE = "Import Payments"
const val IMPORT_PAYMENT_SUB_TITLE = "Click here to import data from file."
Expand Down
19 changes: 11 additions & 8 deletions core/common/src/main/java/com/niyaj/common/tags/ProductTestTags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,25 @@ object ProductTestTags {

const val PRODUCT_TAG = "Product-"

const val EXPORT_PRODUCTS_TITLE = "Export Products"
const val EXPORT_PRODUCTS_BTN_TEXT = "Export Products"
const val EXPORT_PRODUCTS_BTN = "Export Products"
const val PRODUCT_SETTINGS_TITLE = "Product Settings"

const val IMPORT_PRODUCTS_TITLE = "Import Products"
const val IMPORT_PRODUCTS_BTN_TEXT = "Import Products"
const val IMPORT_PRODUCTS_SUB_TITLE = "Click here to import product from file."
const val IMPORT_PRODUCTS_OPN_FILE = "Open File"
const val IMPORT_PRODUCTS_NOTE_TEXT = "Make sure to open products.json file."
const val IMPORT_PRODUCTS_NOTE = "Make sure to import categories before importing products."

const val INCREASE_PRODUCTS_TITLE = "Increase Price"
const val INCREASE_PRODUCTS_TEXT_FIELD = "Product Price"
const val INCREASE_PRODUCTS_BTN_TEXT = "Increase Price"
const val INCREASE_PRODUCTS_SUB_TITLE = "Click here to increase product price."

const val DECREASE_PRODUCTS_TITLE = "Decrease Price"
const val DECREASE_PRODUCTS_TEXT_FIELD = "Product Price"
const val DECREASE_PRODUCTS_BTN_TEXT = "Decrease Price"
const val DECREASE_PRODUCTS_SUB_TITLE = "Click here to decrease product price."
const val PRODUCT_PRICE_TEXT_FIELD = "Product Price"

const val EXPORT_PRODUCTS_TITLE = "Export Products"
const val EXPORT_PRODUCTS_SUB_TITLE = "Click here to export product to file."
const val EXPORTED_PRODUCTS_FILE_NAME = "products"

const val VIEW_CATEGORY_TITLE = "View Categories"
const val VIEW_CATEGORY_SUB_TITLE = "Click here to view categories."
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,17 @@ class CartOrderRepositoryImpl(
withContext(ioDispatcher) {
addressDao.getAddressById(cartOrder.addressId)?.asExternalModel()
}
} else null
} else {
null
}

val customer = if (cartOrder.orderType != OrderType.DineIn) {
withContext(ioDispatcher) {
customerDao.getCustomerById(cartOrder.customerId)?.asExternalModel()
}
} else null
} else {
null
}

CartOrder(
orderId = cartOrder.orderId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ class CartRepositoryImpl(
customerPhone = itemDto.customerPhone,
customerAddress = itemDto.customerAddress,
updatedAt = (
itemDto.cartOrder.updatedAt
?: itemDto.cartOrder.createdAt
).toTimeSpan,
itemDto.cartOrder.updatedAt
?: itemDto.cartOrder.createdAt
).toTimeSpan,
orderPrice = itemDto.orderPrice.totalPrice,
deliveryPartnerId = itemDto.cartOrder.deliveryPartnerId,
)
Expand Down
2 changes: 1 addition & 1 deletion core/model/src/main/java/com/niyaj/model/Absent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ data class Absent(
val createdAt: Long = System.currentTimeMillis(),

val updatedAt: Long? = null,
)
)
2 changes: 1 addition & 1 deletion core/model/src/main/java/com/niyaj/model/CartOrder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ fun List<CartOrder>.filterCartOrder(searchText: String): List<CartOrder> {
} else {
this
}
}
}
19 changes: 11 additions & 8 deletions core/model/src/main/java/com/niyaj/model/EmployeeWithAbsents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,33 @@ data class EmployeeWithAbsents(
val absents: List<Absent> = emptyList(),
)


/**
* Filter absent employee by date and absent reason
*/
fun Absent.filterAbsent(searchText: String): Boolean {
return this.absentDate.toJoinedDate.contains(searchText, true) ||
this.absentReason.contains(searchText, true) ||
this.absentDate.toDate.contains(searchText, true) ||
this.createdAt.toDateString.contains(searchText, true)
this.absentReason.contains(searchText, true) ||
this.absentDate.toDate.contains(searchText, true) ||
this.createdAt.toDateString.contains(searchText, true)
}

fun List<Absent>.filterAbsent(searchText: String): List<Absent> {
return if (this.isNotEmpty()) {
this.filter { it.filterAbsent(searchText) }
}else this
} else {
this
}
}

fun List<EmployeeWithAbsents>.filterEmployeeWithAbsent(searchText: String): List<EmployeeWithAbsents> {
return if (searchText.isNotEmpty()) {
this.map {
EmployeeWithAbsents(
employee = it.employee,
absents = it.absents.filterAbsent(searchText)
absents = it.absents.filterAbsent(searchText),
)
}
}else this
}
} else {
this
}
}
16 changes: 10 additions & 6 deletions core/model/src/main/java/com/niyaj/model/EmployeeWithPayments.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ fun List<Payment>.searchPayment(searchText: String): List<Payment> {
return if (searchText.isNotEmpty()) {
this.filter {
it.paymentAmount.contains(searchText, true) ||
it.paymentType.name.contains(searchText, true) ||
it.paymentDate.toDate.contains(searchText, true) ||
it.paymentMode.name.contains(searchText, true) ||
it.paymentNote.contains(searchText, true)
it.paymentType.name.contains(searchText, true) ||
it.paymentDate.toDate.contains(searchText, true) ||
it.paymentMode.name.contains(searchText, true) ||
it.paymentNote.contains(searchText, true)
}
} else this
} else {
this
}
}

fun List<EmployeeWithPayments>.searchEmployeeWithPayments(searchText: String): List<EmployeeWithPayments> {
Expand All @@ -47,5 +49,7 @@ fun List<EmployeeWithPayments>.searchEmployeeWithPayments(searchText: String): L
payments = it.payments.searchPayment(searchText),
)
}
} else this
} else {
this
}
}
12 changes: 0 additions & 12 deletions core/model/src/main/java/com/niyaj/model/Product.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ data class Product(
val createdAt: Long,

val updatedAt: Long? = null,

)

/**
Expand All @@ -55,14 +54,3 @@ fun List<Product>.filterProducts(searchText: String): List<Product> {
this
}
}

/**
* Filter product by category
*/
fun Product.filterByCategory(categoryId: String): Boolean {
return if (categoryId.isNotEmpty()) {
this.categoryId == categoryId.toInt()
} else {
true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ fun CartAddOnItems(
}
}


@DevicePreviews
@Composable
private fun CartAddOnItemsPreview(
Expand All @@ -86,7 +85,7 @@ private fun CartAddOnItemsPreview(
modifier = modifier,
addOnItems = addOnItems,
selectedAddOnItem = selectedAddOnItem,
onClick = {}
onClick = {},
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ fun CartChargesItem(
}
}


@DevicePreviews
@Composable
private fun CartChargesItemPreview(
Expand All @@ -76,7 +75,7 @@ private fun CartChargesItemPreview(
modifier = modifier,
chargesList = chargesList,
selectedItems = selectedItems,
onClick = {}
onClick = {},
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fun CartDeliveryPartners(
@Composable
private fun CartDeliveryPartnersPreview(
modifier: Modifier = Modifier,
deliveryPartners: List<EmployeeNameAndId> = CardOrderPreviewData.sampleEmployeeNameAndIds
deliveryPartners: List<EmployeeNameAndId> = CardOrderPreviewData.sampleEmployeeNameAndIds,
) {
PoposRoomTheme {
CartDeliveryPartners(
Expand All @@ -92,4 +92,4 @@ private fun CartDeliveryPartnersPreview(
onClick = {},
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,18 @@ private fun CartProduct(
}
}


@DevicePreviews
@Composable
private fun CartItemProductDetailsSectionPreview(
modifier: Modifier = Modifier,
cartProducts: List<CartProductItem> = CartPreviewParameterData.sampleCartProductItems
cartProducts: List<CartProductItem> = CartPreviewParameterData.sampleCartProductItems,
) {
PoposRoomTheme {
CartItemProductDetailsSection(
modifier = modifier,
cartProducts = cartProducts,
decreaseQuantity = {},
increaseQuantity = {}
increaseQuantity = {},
)
}
}
Expand All @@ -229,4 +228,4 @@ private fun CartProductPreview(
increaseQuantity = {},
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fun CartItemTotalPriceSection(
MaterialTheme.colorScheme.primary
} else {
MaterialTheme.colorScheme.secondary
}
},
) = trace("CartItemTotalPriceSection") {
Surface(
modifier = modifier
Expand Down Expand Up @@ -132,7 +132,6 @@ fun CartItemTotalPriceSection(
}
}


@DevicePreviews
@Composable
private fun CartItemTotalPriceSectionPreview(
Expand All @@ -148,7 +147,7 @@ private fun CartItemTotalPriceSectionPreview(
orderType = orderType,
showPrintBtn = orderType == OrderType.DineOut,
onClickPlaceOrder = {},
onClickPrintOrder = {}
onClickPrintOrder = {},
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fun CategoriesData(
}

@Composable
fun CategoriesData(
fun CategoryList(
modifier: Modifier = Modifier,
lazyRowState: LazyListState = rememberLazyListState(),
categories: ImmutableList<Category>,
Expand Down
Loading

0 comments on commit 968ae59

Please sign in to comment.