diff --git a/androidVariant/src/main/java/org/comixedproject/variant/android/view/server/FileItemView.kt b/androidVariant/src/main/java/org/comixedproject/variant/android/view/server/FileItemView.kt index f998a02..7100e51 100644 --- a/androidVariant/src/main/java/org/comixedproject/variant/android/view/server/FileItemView.kt +++ b/androidVariant/src/main/java/org/comixedproject/variant/android/view/server/FileItemView.kt @@ -23,9 +23,6 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.AddCircle -import androidx.compose.material.icons.filled.Check import androidx.compose.material3.CardDefaults import androidx.compose.material3.ElevatedCard import androidx.compose.material3.Icon @@ -37,12 +34,14 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import org.comixedproject.variant.android.DIRECTORY_LIST +import org.comixedproject.variant.android.R import org.comixedproject.variant.android.VariantTheme import org.comixedproject.variant.android.view.BYTES_PER_MB import org.comixedproject.variant.model.library.DirectoryEntry @@ -78,23 +77,39 @@ fun FileItemView( horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier.fillMaxWidth() ) { - if (comicBookFilenameList.contains(fileEntry.filename)) { - IconButton( - onClick = { - - }, - enabled = downloadingState.size < 5 - ) { - Icon(Icons.Filled.Check, contentDescription = fileEntry.title) + if (downloading == null) { + if (comicBookFilenameList.contains(fileEntry.filename)) { + IconButton( + onClick = { }, + enabled = downloadingState.size < 5 + ) { + Icon( + painterResource(id = R.drawable.ic_downloaded_file), + contentDescription = fileEntry.title + ) + } + } else { + IconButton( + onClick = { + onDownloadFile(fileEntry.path, fileEntry.filename) + }, + enabled = downloadingState.size < 5 + ) { + Icon( + painterResource(R.drawable.ic_download_file), + contentDescription = fileEntry.title + ) + } } } else { IconButton( - onClick = { - onDownloadFile(fileEntry.path, fileEntry.filename) - }, + onClick = { }, enabled = downloadingState.size < 5 ) { - Icon(Icons.Filled.AddCircle, contentDescription = fileEntry.title) + Icon( + painterResource(R.drawable.ic_downloading_file), + contentDescription = fileEntry.title + ) } } @@ -107,18 +122,19 @@ fun FileItemView( maxLines = 1, overflow = TextOverflow.Ellipsis ) - Text( - text = "${fileEntry.filename}", - style = MaterialTheme.typography.bodySmall, - fontWeight = FontWeight.Bold, - textAlign = TextAlign.Left, - maxLines = 1, - overflow = TextOverflow.Ellipsis - ) - downloading?.let { - val received = it.received - val total = it.total + if (downloading == null) { + Text( + text = "${fileEntry.filename}", + style = MaterialTheme.typography.bodySmall, + fontWeight = FontWeight.Bold, + textAlign = TextAlign.Left, + maxLines = 1, + overflow = TextOverflow.Ellipsis + ) + } else { + val received = downloading.received + val total = downloading.total val progress = when (received > 0) { true -> (received.toFloat() / total.toFloat()) false -> 0.0 @@ -146,9 +162,10 @@ fun FileItemView( @Composable @Preview fun FileItemViewPreview() { + val fileEntry = DIRECTORY_LIST.filter { !it.isDirectory }.first() VariantTheme { FileItemView( - DIRECTORY_LIST.filter { !it.isDirectory }.first(), + fileEntry, listOf(), listOf(), onDownloadFile = { _, _ -> }) diff --git a/androidVariant/src/main/res/drawable-anydpi/ic_download_file.xml b/androidVariant/src/main/res/drawable-anydpi/ic_download_file.xml new file mode 100644 index 0000000..fc2f641 --- /dev/null +++ b/androidVariant/src/main/res/drawable-anydpi/ic_download_file.xml @@ -0,0 +1,20 @@ + + + + + + diff --git a/androidVariant/src/main/res/drawable-anydpi/ic_downloaded_file.xml b/androidVariant/src/main/res/drawable-anydpi/ic_downloaded_file.xml new file mode 100644 index 0000000..a6137e1 --- /dev/null +++ b/androidVariant/src/main/res/drawable-anydpi/ic_downloaded_file.xml @@ -0,0 +1,11 @@ + + + diff --git a/androidVariant/src/main/res/drawable-anydpi/ic_downloading_file.xml b/androidVariant/src/main/res/drawable-anydpi/ic_downloading_file.xml new file mode 100644 index 0000000..b473b33 --- /dev/null +++ b/androidVariant/src/main/res/drawable-anydpi/ic_downloading_file.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/androidVariant/src/main/res/drawable-hdpi/ic_download_file.png b/androidVariant/src/main/res/drawable-hdpi/ic_download_file.png new file mode 100644 index 0000000..1206051 Binary files /dev/null and b/androidVariant/src/main/res/drawable-hdpi/ic_download_file.png differ diff --git a/androidVariant/src/main/res/drawable-hdpi/ic_downloaded_file.png b/androidVariant/src/main/res/drawable-hdpi/ic_downloaded_file.png new file mode 100644 index 0000000..0c1e302 Binary files /dev/null and b/androidVariant/src/main/res/drawable-hdpi/ic_downloaded_file.png differ diff --git a/androidVariant/src/main/res/drawable-hdpi/ic_downloading_file.png b/androidVariant/src/main/res/drawable-hdpi/ic_downloading_file.png new file mode 100644 index 0000000..926e456 Binary files /dev/null and b/androidVariant/src/main/res/drawable-hdpi/ic_downloading_file.png differ diff --git a/androidVariant/src/main/res/drawable-mdpi/ic_download_file.png b/androidVariant/src/main/res/drawable-mdpi/ic_download_file.png new file mode 100644 index 0000000..637567a Binary files /dev/null and b/androidVariant/src/main/res/drawable-mdpi/ic_download_file.png differ diff --git a/androidVariant/src/main/res/drawable-mdpi/ic_downloaded_file.png b/androidVariant/src/main/res/drawable-mdpi/ic_downloaded_file.png new file mode 100644 index 0000000..ce9f71e Binary files /dev/null and b/androidVariant/src/main/res/drawable-mdpi/ic_downloaded_file.png differ diff --git a/androidVariant/src/main/res/drawable-mdpi/ic_downloading_file.png b/androidVariant/src/main/res/drawable-mdpi/ic_downloading_file.png new file mode 100644 index 0000000..367821f Binary files /dev/null and b/androidVariant/src/main/res/drawable-mdpi/ic_downloading_file.png differ diff --git a/androidVariant/src/main/res/drawable-xhdpi/ic_download_file.png b/androidVariant/src/main/res/drawable-xhdpi/ic_download_file.png new file mode 100644 index 0000000..873f4ec Binary files /dev/null and b/androidVariant/src/main/res/drawable-xhdpi/ic_download_file.png differ diff --git a/androidVariant/src/main/res/drawable-xhdpi/ic_downloaded_file.png b/androidVariant/src/main/res/drawable-xhdpi/ic_downloaded_file.png new file mode 100644 index 0000000..e069f23 Binary files /dev/null and b/androidVariant/src/main/res/drawable-xhdpi/ic_downloaded_file.png differ diff --git a/androidVariant/src/main/res/drawable-xhdpi/ic_downloading_file.png b/androidVariant/src/main/res/drawable-xhdpi/ic_downloading_file.png new file mode 100644 index 0000000..2106d77 Binary files /dev/null and b/androidVariant/src/main/res/drawable-xhdpi/ic_downloading_file.png differ diff --git a/androidVariant/src/main/res/drawable-xxhdpi/ic_download_file.png b/androidVariant/src/main/res/drawable-xxhdpi/ic_download_file.png new file mode 100644 index 0000000..74f59e8 Binary files /dev/null and b/androidVariant/src/main/res/drawable-xxhdpi/ic_download_file.png differ diff --git a/androidVariant/src/main/res/drawable-xxhdpi/ic_downloaded_file.png b/androidVariant/src/main/res/drawable-xxhdpi/ic_downloaded_file.png new file mode 100644 index 0000000..0e2f148 Binary files /dev/null and b/androidVariant/src/main/res/drawable-xxhdpi/ic_downloaded_file.png differ diff --git a/androidVariant/src/main/res/drawable-xxhdpi/ic_downloading_file.png b/androidVariant/src/main/res/drawable-xxhdpi/ic_downloading_file.png new file mode 100644 index 0000000..efc6cc8 Binary files /dev/null and b/androidVariant/src/main/res/drawable-xxhdpi/ic_downloading_file.png differ diff --git a/iosVariant/iosVariant/Assets.xcassets/download_file.imageset/Contents.json b/iosVariant/iosVariant/Assets.xcassets/download_file.imageset/Contents.json new file mode 100644 index 0000000..73a0dda --- /dev/null +++ b/iosVariant/iosVariant/Assets.xcassets/download_file.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "reshot-icon-download-X8QHVZ4YUF.svg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iosVariant/iosVariant/Assets.xcassets/download_file.imageset/reshot-icon-download-X8QHVZ4YUF.svg b/iosVariant/iosVariant/Assets.xcassets/download_file.imageset/reshot-icon-download-X8QHVZ4YUF.svg new file mode 100644 index 0000000..607545e --- /dev/null +++ b/iosVariant/iosVariant/Assets.xcassets/download_file.imageset/reshot-icon-download-X8QHVZ4YUF.svg @@ -0,0 +1 @@ +11.download \ No newline at end of file diff --git a/iosVariant/iosVariant/Assets.xcassets/downloaded_file.imageset/Contents.json b/iosVariant/iosVariant/Assets.xcassets/downloaded_file.imageset/Contents.json new file mode 100644 index 0000000..db67733 --- /dev/null +++ b/iosVariant/iosVariant/Assets.xcassets/downloaded_file.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "reshot-icon-book-SG9XMHP48E.svg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iosVariant/iosVariant/Assets.xcassets/downloaded_file.imageset/reshot-icon-book-SG9XMHP48E.svg b/iosVariant/iosVariant/Assets.xcassets/downloaded_file.imageset/reshot-icon-book-SG9XMHP48E.svg new file mode 100644 index 0000000..42644df --- /dev/null +++ b/iosVariant/iosVariant/Assets.xcassets/downloaded_file.imageset/reshot-icon-book-SG9XMHP48E.svg @@ -0,0 +1,10 @@ + + + + + + diff --git a/iosVariant/iosVariant/Assets.xcassets/downloading_file.imageset/Contents.json b/iosVariant/iosVariant/Assets.xcassets/downloading_file.imageset/Contents.json new file mode 100644 index 0000000..3600d1c --- /dev/null +++ b/iosVariant/iosVariant/Assets.xcassets/downloading_file.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "reshot-icon-download-2CGFX4ZBLJ.svg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iosVariant/iosVariant/Assets.xcassets/downloading_file.imageset/reshot-icon-download-2CGFX4ZBLJ.svg b/iosVariant/iosVariant/Assets.xcassets/downloading_file.imageset/reshot-icon-download-2CGFX4ZBLJ.svg new file mode 100644 index 0000000..3c9a759 --- /dev/null +++ b/iosVariant/iosVariant/Assets.xcassets/downloading_file.imageset/reshot-icon-download-2CGFX4ZBLJ.svg @@ -0,0 +1 @@ +Artboard-154 \ No newline at end of file diff --git a/iosVariant/iosVariant/Views/Servers/FileItemView.swift b/iosVariant/iosVariant/Views/Servers/FileItemView.swift index fa922e0..265e334 100644 --- a/iosVariant/iosVariant/Views/Servers/FileItemView.swift +++ b/iosVariant/iosVariant/Views/Servers/FileItemView.swift @@ -28,7 +28,7 @@ struct FileItemView: View { var onDownloadFile: (String, String) -> Void - var isDownloaded: Bool { + var downloaded: Bool { return comicBookFiles.contains(entry.filename) } @@ -52,11 +52,23 @@ struct FileItemView: View { var body: some View { HStack { - if isDownloaded { + if downloaded { Button { } label: { - Image(systemName: "checkmark.circle.fill") + Image("downloaded_file") + .resizable() + .scaledToFit() + .frame(width: 32) + } + } else if downloading { + Button { + + } label: { + Image("downloading_file") + .resizable() + .scaledToFit() + .frame(width: 32) } } else { Button { @@ -66,7 +78,10 @@ struct FileItemView: View { ) onDownloadFile(entry.path, entry.filename) } label: { - Image(systemName: "plus.circle.fill") + Image("download_file") + .resizable() + .scaledToFit() + .frame(width: 32) } } @@ -74,14 +89,14 @@ struct FileItemView: View { Text(entry.title) .font(.headline) - Text(entry.filename) - .font(.subheadline) - if downloading { HStack { Text("\(fileSize) MB") ProgressView(value: downloadProgress) } + } else { + Text(entry.filename) + .font(.subheadline) } } } diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/viewmodel/VariantViewModel.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/viewmodel/VariantViewModel.kt index 17d2834..8e5db88 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/viewmodel/VariantViewModel.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/viewmodel/VariantViewModel.kt @@ -254,9 +254,10 @@ open class VariantViewModel( } val finalState = - _browsingState.value.downloadingState.filter { !(it.path == path) } + _browsingState.value.downloadingState.filter { !(it.path.equals(path)) } .toMutableList() doUpdateDownloadingState(finalState) + loadLibraryContents() } } @@ -330,8 +331,10 @@ open class VariantViewModel( path.directoryFiles() .filter { if (!ignored.contains(it.name)) { + Log.debug(TAG, "File is not ignored: ${it.name}") true } else { + Log.debug(TAG, "File is ignored: ${it.name}") false } }