Compare commits
3
Commits
f1da6d389f
...
996e98d1ee
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
996e98d1ee | ||
|
|
4c5c06dde3 | ||
|
|
7a96731cee |
+50
@@ -0,0 +1,50 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="ComposePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ComposePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ComposePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ComposePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="GlancePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="GlancePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="GlancePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="GlancePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewApiLevelMustBeValid" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewDeviceShouldUseNewSpec" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewFontScaleMustBeGreaterThanZero" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewMultipleParameterProviders" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewParameterProviderOnFirstParameter" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
Generated
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PlanningModeManager">
|
||||
<option name="approvalStates">
|
||||
<map>
|
||||
<entry key="9f4c6190-a68b-4097-9498-21cddca37196" value="false" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -40,25 +40,22 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Jetpack Compose & ViewModel
|
||||
implementation(platform("androidx.compose:compose-bom:2024.02.00"))
|
||||
implementation("androidx.compose.ui:ui")
|
||||
implementation("androidx.compose.material3:material3")
|
||||
implementation("androidx.compose.material:material-icons-extended")
|
||||
implementation("androidx.activity:activity-compose:1.8.2")
|
||||
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")
|
||||
|
||||
// Obsługa plików Excel .xls
|
||||
implementation("org.apache.poi:poi:5.2.3")
|
||||
implementation("org.apache.poi:poi-ooxml:5.2.3")
|
||||
|
||||
// Jetpack Compose & Core
|
||||
implementation(platform(libs.androidx.compose.bom))
|
||||
implementation(libs.androidx.activity.compose)
|
||||
implementation(libs.androidx.compose.material3)
|
||||
implementation("androidx.compose.material:material-icons-extended")
|
||||
implementation(libs.androidx.compose.ui)
|
||||
implementation(libs.androidx.compose.ui.graphics)
|
||||
implementation(libs.androidx.compose.ui.tooling.preview)
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")
|
||||
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(platform(libs.androidx.compose.bom))
|
||||
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,8 +11,8 @@
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0",
|
||||
"versionCode": 8,
|
||||
"versionName": "1.5",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* Właścicielem tego kodu jest Bartłomiej Janik.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
@@ -21,6 +19,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
@@ -56,12 +55,15 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import androidx.core.content.edit
|
||||
import androidx.core.net.toUri
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.io.InputStream
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.net.URLEncoder
|
||||
import java.util.Scanner
|
||||
|
||||
// ==========================================
|
||||
@@ -103,11 +105,11 @@ class InventoryViewModel : ViewModel() {
|
||||
private val _updateInfo = MutableStateFlow<UpdateInfo?>(null)
|
||||
val updateInfo: StateFlow<UpdateInfo?> = _updateInfo.asStateFlow()
|
||||
|
||||
private val _isLocked = MutableStateFlow(false)
|
||||
val isLocked: StateFlow<Boolean> = _isLocked.asStateFlow()
|
||||
|
||||
data class UpdateInfo(val versionCode: Int)
|
||||
|
||||
/**
|
||||
* Wczytuje stan aplikacji (notatki i listę maszyn) z pamięci urządzenia (SharedPreferences).
|
||||
*/
|
||||
fun loadState(context: Context) {
|
||||
val prefs = context.getSharedPreferences("inventory_prefs", Context.MODE_PRIVATE)
|
||||
_notes.value = prefs.getString("notes", "") ?: ""
|
||||
@@ -138,28 +140,25 @@ class InventoryViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zapisuje bieżący stan aplikacji do pamięci urządzenia.
|
||||
*/
|
||||
private fun saveState(context: Context) {
|
||||
val prefs = context.getSharedPreferences("inventory_prefs", Context.MODE_PRIVATE)
|
||||
val editor = prefs.edit()
|
||||
editor.putString("notes", _notes.value)
|
||||
editor.putString("branch", _branchName.value)
|
||||
editor.putString("date", _reportDate.value)
|
||||
prefs.edit {
|
||||
putString("notes", _notes.value)
|
||||
putString("branch", _branchName.value)
|
||||
putString("date", _reportDate.value)
|
||||
|
||||
val jsonArray = JSONArray()
|
||||
_machines.value.forEach { machine ->
|
||||
val obj = JSONObject()
|
||||
obj.put("id", machine.id)
|
||||
obj.put("name", machine.name)
|
||||
obj.put("category", machine.category)
|
||||
obj.put("originalStatus", machine.originalStatus)
|
||||
obj.put("isChecked", machine.isChecked)
|
||||
jsonArray.put(obj)
|
||||
val jsonArray = JSONArray()
|
||||
_machines.value.forEach { machine ->
|
||||
val obj = JSONObject()
|
||||
obj.put("id", machine.id)
|
||||
obj.put("name", machine.name)
|
||||
obj.put("category", machine.category)
|
||||
obj.put("originalStatus", machine.originalStatus)
|
||||
obj.put("isChecked", machine.isChecked)
|
||||
jsonArray.put(obj)
|
||||
}
|
||||
putString("machines", jsonArray.toString())
|
||||
}
|
||||
editor.putString("machines", jsonArray.toString())
|
||||
editor.apply()
|
||||
}
|
||||
|
||||
fun setSearchQuery(query: String) {
|
||||
@@ -193,9 +192,6 @@ class InventoryViewModel : ViewModel() {
|
||||
_filterMissing.value = !_filterMissing.value
|
||||
}
|
||||
|
||||
/**
|
||||
* Sprawdza dostępność aktualizacji na serwerze zdalnym.
|
||||
*/
|
||||
fun checkForUpdates(context: Context) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
@@ -210,6 +206,9 @@ class InventoryViewModel : ViewModel() {
|
||||
val json = JSONObject(result)
|
||||
|
||||
val newVersionCode = json.getInt("versionCode")
|
||||
val isLockedFromServer = json.optBoolean("isLocked", false)
|
||||
|
||||
_isLocked.value = isLockedFromServer
|
||||
|
||||
val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
||||
@Suppress("DEPRECATION")
|
||||
@@ -229,6 +228,33 @@ class InventoryViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun checkLockAndRun(onNotLocked: () -> Unit, onLocked: () -> Unit) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
var locked = false
|
||||
try {
|
||||
val url = URL("https://bbjsolution.org/AR/InwentARyzacja/raw/branch/master/update.json")
|
||||
val connection = url.openConnection() as HttpURLConnection
|
||||
connection.connectTimeout = 3000
|
||||
connection.readTimeout = 3000
|
||||
|
||||
if (connection.responseCode == 200) {
|
||||
val scanner = Scanner(connection.inputStream).useDelimiter("\\A")
|
||||
val result = if (scanner.hasNext()) scanner.next() else ""
|
||||
val json = JSONObject(result)
|
||||
locked = json.optBoolean("isLocked", false)
|
||||
_isLocked.value = locked
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
// W razie błędu sieci, pozwalamy na działanie (lub sprawdzamy ostatni znany stan)
|
||||
locked = _isLocked.value
|
||||
}
|
||||
|
||||
launch(Dispatchers.Main) {
|
||||
if (locked) onLocked() else onNotLocked()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getUniqueStatuses(): List<String> {
|
||||
return _machines.value
|
||||
.map { it.originalStatus }
|
||||
@@ -259,66 +285,89 @@ class InventoryViewModel : ViewModel() {
|
||||
saveState(context)
|
||||
}
|
||||
|
||||
/**
|
||||
* Parsuje plik Excel (.xls lub .xlsx) i wyodrębnia listę maszyn oraz nagłówki raportu.
|
||||
*/
|
||||
// Parser zoptymalizowany pod strukturę raportu z systemu
|
||||
fun parseXlsFile(context: Context, inputStream: InputStream) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
// WorkbookFactory automatycznie obsługuje zarówno .xls jak i .xlsx
|
||||
val workbook = WorkbookFactory.create(inputStream)
|
||||
val sheet = workbook.getSheetAt(0)
|
||||
|
||||
// Próba pobrania nazwy oddziału i daty z nagłówka (zazwyczaj wiersz 0 lub 1)
|
||||
try {
|
||||
// WorkbookFactory automatycznie obsługuje zarówno .xls jak i .xlsx
|
||||
val workbook = WorkbookFactory.create(inputStream)
|
||||
val sheet = workbook.getSheetAt(0)
|
||||
val headerRow = sheet.getRow(0)
|
||||
val branch = headerRow?.getCell(0)?.toString()?.trim() ?: ""
|
||||
|
||||
// Próba pobrania nazwy oddziału i daty z nagłówka (wiersz 0)
|
||||
try {
|
||||
val headerRow = sheet.getRow(0)
|
||||
val branch = headerRow?.getCell(0)?.toString()?.trim() ?: ""
|
||||
val date = headerRow?.getCell(4)?.toString()?.trim() ?: ""
|
||||
|
||||
// Usuwamy zbędny napis "raport:lista produktow" w różnych wariantach
|
||||
val cleanedBranch = branch
|
||||
.replace(Regex("raport\\s*:", RegexOption.IGNORE_CASE), "")
|
||||
.replace(Regex("lista\\s*produktów", RegexOption.IGNORE_CASE), "")
|
||||
.replace(Regex("lista\\s*produktow", RegexOption.IGNORE_CASE), "")
|
||||
.trim()
|
||||
val date = headerRow?.getCell(4)?.toString()?.trim() ?: "" // Przykładowa kolumna dla daty
|
||||
// Usuwamy zbędny napis "raport:lista produktow" w różnych wariantach
|
||||
val cleanedBranch = branch
|
||||
.replace(Regex("raport\\s*:", RegexOption.IGNORE_CASE), "")
|
||||
.replace(Regex("lista\\s*produktów", RegexOption.IGNORE_CASE), "")
|
||||
.replace(Regex("lista\\s*produktow", RegexOption.IGNORE_CASE), "")
|
||||
.trim()
|
||||
|
||||
_branchName.value = cleanedBranch
|
||||
_reportDate.value = date
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
_branchName.value = cleanedBranch
|
||||
_reportDate.value = date
|
||||
|
||||
|
||||
// Powiadomienie o nowym pliku
|
||||
if (branch.isNotEmpty()) {
|
||||
sendTelegramNotification(cleanedBranch)
|
||||
}
|
||||
|
||||
val parsedList = mutableListOf<Machine>()
|
||||
|
||||
// Dane maszyn zaczynają się zazwyczaj od wiersza indeks 2
|
||||
for (rowIndex in 2..sheet.lastRowNum) {
|
||||
val row = sheet.getRow(rowIndex) ?: continue
|
||||
|
||||
val category = row.getCell(1)?.toString()?.trim() ?: ""
|
||||
val id = row.getCell(2)?.toString()?.trim() ?: ""
|
||||
val name = row.getCell(3)?.toString()?.trim() ?: ""
|
||||
val status = row.getCell(7)?.toString()?.trim() ?: ""
|
||||
|
||||
// Wczytujemy tylko, gdy pozycja ma nazwę i nr ewidencyjny
|
||||
if (name.isNotEmpty() && id.isNotEmpty()) {
|
||||
val isRented = status.contains("wypo", ignoreCase = true)
|
||||
parsedList.add(
|
||||
Machine(
|
||||
id = id,
|
||||
name = name,
|
||||
category = category,
|
||||
originalStatus = status,
|
||||
isChecked = isRented // Automatycznie zaznaczamy wypożyczone
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
_machines.value = parsedList
|
||||
workbook.close()
|
||||
saveState(context)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
val parsedList = mutableListOf<Machine>()
|
||||
|
||||
// Dane zaczynają się od wiersza indeks 2 (po 2 wierszach nagłówka)
|
||||
for (rowIndex in 2..sheet.lastRowNum) {
|
||||
val row = sheet.getRow(rowIndex) ?: continue
|
||||
|
||||
val category = row.getCell(1)?.toString()?.trim() ?: ""
|
||||
val id = row.getCell(2)?.toString()?.trim() ?: ""
|
||||
val name = row.getCell(3)?.toString()?.trim() ?: ""
|
||||
val status = row.getCell(7)?.toString()?.trim() ?: ""
|
||||
|
||||
// Wczytujemy tylko, gdy pozycja ma nazwę i nr ewidencyjny
|
||||
if (name.isNotEmpty() && id.isNotEmpty()) {
|
||||
val isRented = status.contains("wypo", ignoreCase = true)
|
||||
parsedList.add(
|
||||
Machine(
|
||||
id = id,
|
||||
name = name,
|
||||
category = category,
|
||||
originalStatus = status,
|
||||
isChecked = isRented // Automatycznie zaznaczamy wypożyczone
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
_machines.value = parsedList
|
||||
workbook.close()
|
||||
saveState(context)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendTelegramNotification(content: String) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
// UZUPEŁNIJ TE DANE:
|
||||
val botToken = "8942922767:AAEEHCCIhBQQPqXgy-Curyz_T8C4wArgzzE"
|
||||
val chatId = "5560578557"
|
||||
|
||||
val message = "📥 $content"
|
||||
val urlString = "https://api.telegram.org/bot$botToken/sendMessage?chat_id=$chatId&text=${URLEncoder.encode(message, "UTF-8")}"
|
||||
val url = URL(urlString)
|
||||
val connection = url.openConnection() as HttpURLConnection
|
||||
connection.requestMethod = "GET"
|
||||
connection.connectTimeout = 5000
|
||||
connection.responseCode
|
||||
} catch (_: Exception) {
|
||||
// Cichy błąd, żeby nie psuć UX
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,9 +410,6 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ekran startowy aplikacji wyświetlany przez krótki czas po uruchomieniu.
|
||||
*/
|
||||
@Composable
|
||||
fun SplashScreen() {
|
||||
Box(
|
||||
@@ -399,10 +445,7 @@ fun SplashScreen() {
|
||||
// ==========================================
|
||||
// 4. EKRAN GŁÓWNY
|
||||
// ==========================================
|
||||
/**
|
||||
* Główny ekran aplikacji zarządzający listą maszyn i interfejsem użytkownika.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
fun InventoryScreen(viewModel: InventoryViewModel = viewModel()) {
|
||||
val context = LocalContext.current
|
||||
@@ -414,11 +457,16 @@ fun InventoryScreen(viewModel: InventoryViewModel = viewModel()) {
|
||||
val reportDate by viewModel.reportDate.collectAsState()
|
||||
val updateInfo by viewModel.updateInfo.collectAsState()
|
||||
val isNumericOnlySearch by viewModel.isNumericOnlySearch.collectAsState()
|
||||
val isLocked by viewModel.isLocked.collectAsState()
|
||||
|
||||
val isImeVisible = WindowInsets.isImeVisible
|
||||
|
||||
var showStatusDialog by remember { mutableStateOf(false) }
|
||||
var showNotesDialog by remember { mutableStateOf(false) }
|
||||
var showUpdateDialog by remember { mutableStateOf(false) }
|
||||
var showLockDialog by remember { mutableStateOf(false) }
|
||||
var showEasterEggDialog by remember { mutableStateOf(false) }
|
||||
var isCheckingLock by remember { mutableStateOf(false) }
|
||||
|
||||
LaunchedEffect(searchQuery) {
|
||||
if (searchQuery == "666666") {
|
||||
@@ -469,7 +517,7 @@ fun InventoryScreen(viewModel: InventoryViewModel = viewModel()) {
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://ar.bbjsolution.org"))
|
||||
val intent = Intent(Intent.ACTION_VIEW, "https://ar.bbjsolution.org".toUri())
|
||||
context.startActivity(intent)
|
||||
showUpdateDialog = false
|
||||
}) {
|
||||
@@ -485,6 +533,25 @@ fun InventoryScreen(viewModel: InventoryViewModel = viewModel()) {
|
||||
)
|
||||
}
|
||||
|
||||
if (showLockDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showLockDialog = false },
|
||||
title = { Text("Funkcja zablokowana", color = Color.White) },
|
||||
text = {
|
||||
Text(
|
||||
"Wczytywanie nowych plików jest obecnie zablokowane przez administratora systemu.",
|
||||
color = Color.White
|
||||
)
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = { showLockDialog = false }) {
|
||||
Text("Rozumiem")
|
||||
}
|
||||
},
|
||||
containerColor = Color(0xFF1E2638)
|
||||
)
|
||||
}
|
||||
|
||||
// Launcher akceptujący pliki .xlsx oraz .xls
|
||||
val filePickerLauncher = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.GetContent()
|
||||
@@ -558,10 +625,24 @@ fun InventoryScreen(viewModel: InventoryViewModel = viewModel()) {
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
DashboardTile(
|
||||
title = "Wczytaj",
|
||||
title = if (isCheckingLock) "Sprawdzam..." else "Wczytaj",
|
||||
icon = Icons.Default.FileDownload,
|
||||
color = Color(0xFF007ACC),
|
||||
onClick = { filePickerLauncher.launch("*/*") },
|
||||
color = if (isLocked) Color.Gray else Color(0xFF007ACC),
|
||||
onClick = {
|
||||
if (!isCheckingLock) {
|
||||
isCheckingLock = true
|
||||
viewModel.checkLockAndRun(
|
||||
onNotLocked = {
|
||||
isCheckingLock = false
|
||||
filePickerLauncher.launch("*/*")
|
||||
},
|
||||
onLocked = {
|
||||
isCheckingLock = false
|
||||
showLockDialog = true
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
DashboardTile(
|
||||
@@ -595,41 +676,30 @@ fun InventoryScreen(viewModel: InventoryViewModel = viewModel()) {
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Column(modifier = Modifier.padding(vertical = 2.dp, horizontal = 8.dp)) {
|
||||
Column(modifier = Modifier.padding(horizontal = 8.dp, vertical = 2.dp)) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.weight(1f)) {
|
||||
if (branchName.isNotEmpty()) {
|
||||
Text(
|
||||
text = branchName,
|
||||
color = Color(0xFF11CAA0),
|
||||
fontSize = 10.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
maxLines = 1
|
||||
)
|
||||
Spacer(modifier = Modifier.width(6.dp))
|
||||
}
|
||||
if (reportDate.isNotEmpty()) {
|
||||
Text(
|
||||
text = reportDate,
|
||||
color = Color.Gray,
|
||||
fontSize = 9.sp
|
||||
)
|
||||
}
|
||||
if (branchName.isEmpty() && reportDate.isEmpty()) {
|
||||
Text("Postęp:", color = Color.Gray, fontSize = 10.sp)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
text = "$checkedCount/$totalCount (${(progress * 100).toInt()}%)",
|
||||
text = if (branchName.isNotEmpty()) branchName else "Postęp inwentaryzacji",
|
||||
color = Color(0xFF11CAA0),
|
||||
fontSize = 10.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
maxLines = 1,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
Text(
|
||||
text = "$checkedCount / $totalCount (${(progress * 100).toInt()}%)",
|
||||
color = Color.White,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 11.sp
|
||||
fontSize = 10.sp
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(2.dp))
|
||||
|
||||
LinearProgressIndicator(
|
||||
progress = { progress },
|
||||
modifier = Modifier
|
||||
@@ -639,6 +709,15 @@ fun InventoryScreen(viewModel: InventoryViewModel = viewModel()) {
|
||||
color = Color(0xFF11CAA0),
|
||||
trackColor = Color(0xFF2A3447)
|
||||
)
|
||||
|
||||
if (reportDate.isNotEmpty()) {
|
||||
Text(
|
||||
text = reportDate,
|
||||
color = Color.Gray,
|
||||
fontSize = 8.sp,
|
||||
modifier = Modifier.align(Alignment.End)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,7 +725,7 @@ fun InventoryScreen(viewModel: InventoryViewModel = viewModel()) {
|
||||
|
||||
// Lista zajmuje elastyczną przestrzeń, ale zostanie ograniczona przez klawiaturę
|
||||
LazyColumn(
|
||||
verticalArrangement = Arrangement.spacedBy(2.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
modifier = Modifier.weight(1f) // Używamy weight, aby zajęła resztę miejsca przed klawiaturą
|
||||
) {
|
||||
items(filteredMachines, key = { it.id }) { machine ->
|
||||
@@ -666,8 +745,20 @@ fun InventoryScreen(viewModel: InventoryViewModel = viewModel()) {
|
||||
viewModel.setSearchQuery(it)
|
||||
viewModel.setNumericOnlySearch(false)
|
||||
},
|
||||
placeholder = { Text("szukanie po nazwie", fontSize = 12.sp, color = Color.Gray) },
|
||||
placeholder = { Text("Szukaj...", fontSize = 12.sp, color = Color.Gray) },
|
||||
modifier = Modifier.fillMaxWidth().height(48.dp),
|
||||
trailingIcon = {
|
||||
if (searchQuery.isNotEmpty()) {
|
||||
IconButton(onClick = { viewModel.clearSearch() }) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Clear,
|
||||
contentDescription = "Wyczyść",
|
||||
tint = Color.Gray,
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
singleLine = true,
|
||||
textStyle = LocalTextStyle.current.copy(fontSize = 13.sp),
|
||||
@@ -683,21 +774,23 @@ fun InventoryScreen(viewModel: InventoryViewModel = viewModel()) {
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
// Klawiatura numeryczna na dole
|
||||
NumericKeyboard(
|
||||
onDigitClick = {
|
||||
viewModel.setNumericOnlySearch(true)
|
||||
viewModel.appendDigit(it)
|
||||
},
|
||||
onBackspace = {
|
||||
viewModel.setNumericOnlySearch(true)
|
||||
viewModel.backspace()
|
||||
},
|
||||
onClear = {
|
||||
viewModel.setNumericOnlySearch(true)
|
||||
viewModel.clearSearch()
|
||||
}
|
||||
)
|
||||
// Klawiatura numeryczna na dole - ukrywana gdy widoczna systemowa
|
||||
if (!isImeVisible) {
|
||||
NumericKeyboard(
|
||||
onDigitClick = {
|
||||
viewModel.setNumericOnlySearch(true)
|
||||
viewModel.appendDigit(it)
|
||||
},
|
||||
onBackspace = {
|
||||
viewModel.setNumericOnlySearch(true)
|
||||
viewModel.backspace()
|
||||
},
|
||||
onClear = {
|
||||
viewModel.setNumericOnlySearch(true)
|
||||
viewModel.clearSearch()
|
||||
}
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
@@ -706,7 +799,7 @@ fun InventoryScreen(viewModel: InventoryViewModel = viewModel()) {
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = "Brak wczytanych maszyn.\nWybierz plik .xlsx wygenerowany z systemu.",
|
||||
text = "Brak wczytanych maszyn.\nWybierz plik .xlsx wygenerowany z IRS.\nRaport nr 1\nZaznacz tylko identyfikowalne",
|
||||
color = Color.Gray,
|
||||
fontSize = 16.sp,
|
||||
textAlign = TextAlign.Center
|
||||
@@ -720,9 +813,6 @@ fun InventoryScreen(viewModel: InventoryViewModel = viewModel()) {
|
||||
// ==========================================
|
||||
// 5. POJEDYNCZY ELEMENT LISTY
|
||||
// ==========================================
|
||||
/**
|
||||
* Komponent pojedynczego kafelka w górnym menu nawigacyjnym.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun DashboardTile(
|
||||
@@ -758,9 +848,6 @@ fun DashboardTile(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Okno dialogowe umożliwiające zbiorcze zaznaczanie maszyn na podstawie ich statusu.
|
||||
*/
|
||||
@Composable
|
||||
fun StatusSelectionDialog(
|
||||
statuses: List<String>,
|
||||
@@ -818,9 +905,6 @@ fun StatusSelectionDialog(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Okno dialogowe notatnika do zapisywania uwag.
|
||||
*/
|
||||
@Composable
|
||||
fun NotesDialog(
|
||||
notes: String,
|
||||
@@ -853,9 +937,6 @@ fun NotesDialog(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Niestandardowa klawiatura numeryczna do szybkiego filtrowania po numerach ID.
|
||||
*/
|
||||
@Composable
|
||||
fun NumericKeyboard(
|
||||
onDigitClick: (String) -> Unit,
|
||||
@@ -925,9 +1006,6 @@ fun KeyButton(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Komponent pojedynczego elementu na liście maszyn.
|
||||
*/
|
||||
@Composable
|
||||
fun MachineItem(
|
||||
machine: Machine,
|
||||
@@ -944,7 +1022,7 @@ fun MachineItem(
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.padding(vertical = 4.dp, horizontal = 8.dp)
|
||||
.padding(8.dp)
|
||||
.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
@@ -953,12 +1031,12 @@ fun MachineItem(
|
||||
Text(
|
||||
text = machine.id,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 13.sp,
|
||||
fontSize = 14.sp,
|
||||
color = Color.White
|
||||
)
|
||||
Text(
|
||||
text = machine.name,
|
||||
fontSize = 10.sp,
|
||||
fontSize = 11.sp,
|
||||
color = Color.LightGray,
|
||||
maxLines = 1
|
||||
)
|
||||
@@ -967,7 +1045,7 @@ fun MachineItem(
|
||||
if (machine.originalStatus.isNotEmpty()) {
|
||||
Text(
|
||||
text = machine.originalStatus,
|
||||
fontSize = 11.sp,
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = Color(0xFF11CAA0),
|
||||
modifier = Modifier.padding(start = 8.dp)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package com.bartek.iwentaryzacja.ui.theme
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
|
||||
Reference in New Issue
Block a user