Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
)
}
}

Expand All @@ -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
Expand Down Expand Up @@ -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 = { _, _ -> })
Expand Down
20 changes: 20 additions & 0 deletions androidVariant/src/main/res/drawable-anydpi/ic_download_file.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#333333"
android:alpha="0.6">
<path
android:fillColor="#FF000000"
android:pathData="M12,24A12,12 0,1 1,24 12,12.013 12.013,0 0,1 12,24ZM12,2A10,10 0,1 0,22 12,10.011 10.011,0 0,0 12,2Z"/>
<path
android:fillColor="#FF000000"
android:pathData="M12,14.414l-4.707,-4.707l1.414,-1.414l3.293,3.293l3.293,-3.293l1.414,1.414l-4.707,4.707z"/>
<path
android:fillColor="#FF000000"
android:pathData="M11,5h2v8h-2z"/>
<path
android:fillColor="#FF000000"
android:pathData="M17,19l-10,0l0,-3l2,0l0,1l6,0l0,-1l2,0l0,3z"/>
</vector>
11 changes: 11 additions & 0 deletions androidVariant/src/main/res/drawable-anydpi/ic_downloaded_file.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="64"
android:viewportHeight="64"
android:tint="#333333"
android:alpha="0.6">
<path
android:pathData="M54,8V0H12C6.49,0 2,4.49 2,10v44c0,5.51 4.49,10 10,10h50V8H54zM6,10c0,-3.31 2.69,-6 6,-6h38v40H12c-2.25,0 -4.33,0.75 -6,2V10zM12,60c-3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6h42V12h4v40H20v4h38v4H12z"
android:fillColor="#231F20"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#333333"
android:alpha="0.6">
<group android:scaleX="1.2631578"
android:scaleY="1.2631578"
android:translateX="-3.1578948"
android:translateY="-3.7894738">
<path
android:pathData="M11.292,16.706a1,1 0,0 0,1.416 0l3,-3a1,1 0,0 0,-1.414 -1.414L13,13.586V4a1,1 0,0 0,-2 0v9.586L9.707,12.293a1,1 0,0 0,-1.414 1.414Z"
android:fillColor="#1c1b1e"/>
<path
android:pathData="M17,19H7a1,1 0,0 0,0 2H17a1,1 0,0 0,0 -2Z"
android:fillColor="#1c1b1e"/>
</group>
</vector>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 22 additions & 7 deletions iosVariant/iosVariant/Views/Servers/FileItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct FileItemView: View {

var onDownloadFile: (String, String) -> Void

var isDownloaded: Bool {
var downloaded: Bool {
return comicBookFiles.contains(entry.filename)
}

Expand All @@ -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 {
Expand All @@ -66,22 +78,25 @@ struct FileItemView: View {
)
onDownloadFile(entry.path, entry.filename)
} label: {
Image(systemName: "plus.circle.fill")
Image("download_file")
.resizable()
.scaledToFit()
.frame(width: 32)
}
}

VStack(alignment: .leading) {
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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down Expand Up @@ -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
}
}
Expand Down