Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added displaying the list of OPDS server entries [#3] #30

Merged
merged 1 commit into from
Nov 23, 2023
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
9 changes: 5 additions & 4 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}
Expand Down Expand Up @@ -46,6 +46,7 @@ kotlin {
implementation(compose.material)
@OptIn(ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
implementation(libs.napier)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
Expand All @@ -66,7 +67,7 @@ android {
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = 1
versionName = "1.0"
versionName = "0.0.1.0"
}
buildFeatures {
compose = true
Expand All @@ -85,8 +86,8 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
dependencies {
debugImplementation(libs.compose.ui.tooling)
Expand Down
49 changes: 26 additions & 23 deletions composeApp/src/commonMain/kotlin/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,44 @@
* along with this program. If not, see <http://www.gnu.org/licenses>
*/

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.Button
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Card
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import io.github.aakira.napier.DebugAntilog
import io.github.aakira.napier.Napier
import org.comixedproject.variant.repository.OPDSServerRepository
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource

@OptIn(ExperimentalResourceApi::class)
@Composable
fun App() {
Napier.base(DebugAntilog())

MaterialTheme {
var greetingText by remember { mutableStateOf("ComiXed Prestige!") }
var showImage by remember { mutableStateOf(false) }
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
Button(onClick = {
greetingText = "ComiXed Prestige"
showImage = !showImage
}) {
Text(greetingText)
}
AnimatedVisibility(showImage) {
Image(
painterResource("compose-multiplatform.xml"),
null
)
val opdsServerRepository = OPDSServerRepository()

LazyColumn {
items(opdsServerRepository.getAllEntries()) { entry ->
Card(modifier = Modifier.fillMaxWidth()) {
Column(modifier = Modifier.fillMaxWidth()) {
Row(modifier = Modifier.fillMaxWidth()) {
Text(text = entry.name)
}
Row(modifier = Modifier.fillMaxWidth()) {
Text(text = entry.url)
}
Row(modifier = Modifier.fillMaxWidth()) {
Text(text = entry.username)
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Variant - A digital comic book reading application for iPad, Android, and desktops.
* Copyright (C) 2023, The ComiXed Project
*
* 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
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses>
*/

package org.comixedproject.variant.model;

/**
* <code>OPDSServerEntry</code> represents a single OPDS server.
*
* @author Darryl L. Pierce
*/
data class OPDSServerEntry(val name: String, val url: String, val username: String, val password: String) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Variant - A digital comic book reading application for iPad, Android, and desktops.
* Copyright (C) 2023, The ComiXed Project
*
* 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
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses>
*/

package org.comixedproject.variant.repository;

import io.github.aakira.napier.Napier
import org.comixedproject.variant.model.OPDSServerEntry

/**
* <code>OPDSServerRepository</code> provides methods for storing and retrieving instanes of {@link OPDSServerEntry}.
*
* @author Darryl L. Pierce
*/
class OPDSServerRepository {
fun getAllEntries(): List<OPDSServerEntry> {
Napier.d { "Loading the list of server entries" }
return listOf(
OPDSServerEntry(
"First Entry",
"http://localhost:7171/opds",
"comixedreader@localhost",
"comixedreader"
),
OPDSServerEntry(
"Second Entry",
"http://localhost:7171/opds",
"comixedreader@localhost",
"comixedreader"
),
OPDSServerEntry(
"Third Entry",
"http://localhost:7171/opds",
"comixedreader@localhost",
"comixedreader"
),
OPDSServerEntry(
"Fourth Entry",
"http://localhost:7171/opds",
"comixedreader@localhost",
"comixedreader"
),
OPDSServerEntry(
"Fifth Entry",
"http://localhost:7171/opds",
"comixedreader@localhost",
"comixedreader"
),
OPDSServerEntry(
"Sixth Entry",
"http://localhost:7171/opds",
"comixedreader@localhost",
"comixedreader"
),
OPDSServerEntry(
"Seventh Entry",
"http://localhost:7171/opds",
"comixedreader@localhost",
"comixedreader"
),
OPDSServerEntry(
"Eighth Entry",
"http://localhost:7171/opds",
"comixedreader@localhost",
"comixedreader"
),
OPDSServerEntry(
"Ninth Entry",
"http://localhost:7171/opds",
"comixedreader@localhost",
"comixedreader"
),
OPDSServerEntry(
"Tenth Entry",
"http://localhost:7171/opds",
"comixedreader@localhost",
"comixedreader"
)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Variant - A digital comic book reading application for iPad, Android, and desktops.
* Copyright (C) 2023, The ComiXed Project
*
* 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
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses>
*/

package org.comixedproject.variant.repository;

import kotlin.test.Test
import kotlin.test.assertFalse
import kotlin.test.assertNotNull

class OPDSServerRepositoryTest {

@Test fun testGetAllEntries() {
val result = OPDSServerRepository().getAllEntries()

assertNotNull(result)
assertFalse(result.isEmpty())
}
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ androidx-test-junit = "1.1.5"
androidx-espresso-core = "3.5.1"
kotlin = "1.9.20"
junit = "4.13.2"
napier = "2.6.1"

[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
Expand All @@ -32,6 +33,7 @@ androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version
androidx-material = { group = "com.google.android.material", name = "material", version.ref = "androidx-material" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidx-constraintlayout" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
napier = { module = "io.github.aakira:napier", version.ref = "napier" }

[plugins]
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
Expand Down
Loading