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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Inkwell

A small **serialized storytelling** platform: authors publish stories as chapters; readers browse, read, follow, and save. Original product — not a Wattpad clone and not an AI writing tool.
A small **serialized storytelling** platform: authors publish stories as chapters; readers browse, read, follow, and save. The product name and fiction are original; the **web and Android UI** follows Wattpad’s layout (orange CTAs, portrait cover rails, Discover/home, story details + reader). Not Wattpad’s logo or assets.

| Piece | Choice | Why |
| --- | --- | --- |
Expand Down
33 changes: 28 additions & 5 deletions android/app/src/main/java/com/inkwell/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.AutoStories
import androidx.compose.material.icons.outlined.BookmarkBorder
import androidx.compose.material.icons.outlined.Home
import androidx.compose.material.icons.outlined.Person
import androidx.compose.material.icons.outlined.Search
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.NavigationBarItemDefaults
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
Expand Down Expand Up @@ -48,34 +52,53 @@ fun InkwellApp() {
val hideBar = route.startsWith("reader") || route == "auth"

Scaffold(
containerColor = MaterialTheme.colorScheme.background,
bottomBar = {
if (!hideBar) {
NavigationBar {
NavigationBar(containerColor = Color.White) {
val colors = NavigationBarItemDefaults.colors(
selectedIconColor = MaterialTheme.colorScheme.primary,
selectedTextColor = MaterialTheme.colorScheme.primary,
indicatorColor = Color(0xFFFFF3EE),
)
NavigationBarItem(
selected = route == "browse" || route.startsWith("story"),
onClick = { nav.tab("browse") },
icon = { Icon(Icons.Outlined.AutoStories, contentDescription = "Browse") },
label = { Text("Browse") },
icon = { Icon(Icons.Outlined.Home, contentDescription = "Home") },
label = { Text("Home") },
colors = colors,
)
NavigationBarItem(
selected = route == "search",
onClick = { nav.tab("search") },
icon = { Icon(Icons.Outlined.Search, contentDescription = "Search") },
label = { Text("Search") },
colors = colors,
)
NavigationBarItem(
selected = route == "library",
onClick = { nav.tab("library") },
icon = { Icon(Icons.Outlined.BookmarkBorder, contentDescription = "Library") },
label = { Text("Library") },
colors = colors,
)
NavigationBarItem(
selected = route == "profile",
onClick = { nav.tab("profile") },
icon = { Icon(Icons.Outlined.Person, contentDescription = "You") },
label = { Text("You") },
colors = colors,
)
}
}
},
) { pad ->
NavHost(navController = nav, startDestination = "browse", modifier = Modifier.padding(pad)) {
composable("browse") {
BrowseScreen(onOpen = { nav.navigate("story/$it") })
BrowseScreen(onOpen = { nav.navigate("story/$it") }, showSearch = false)
}
composable("search") {
BrowseScreen(onOpen = { nav.navigate("story/$it") }, showSearch = true)
}
composable(
"story/{id}",
Expand Down
28 changes: 22 additions & 6 deletions android/app/src/main/java/com/inkwell/app/ui/auth/AuthScreen.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.inkwell.app.ui.auth

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
Expand All @@ -15,10 +21,14 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.inkwell.app.data.Graph
import com.inkwell.app.data.LoginBody
import com.inkwell.app.data.RegisterBody
Expand All @@ -34,9 +44,15 @@ fun AuthScreen(onDone: () -> Unit) {
var error by remember { mutableStateOf<String?>(null) }
val scope = rememberCoroutineScope()

Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
Text(if (register) "Join Inkwell" else "Log in", style = MaterialTheme.typography.headlineMedium, fontFamily = FontFamily.Serif)
Text("Talks to the same JWT API as the web app. Seed: iris / niko / reader — password123")
Column(Modifier.background(Color.White).padding(24.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Box(
Modifier.width(28.dp).height(28.dp).clip(RoundedCornerShape(6.dp)).background(MaterialTheme.colorScheme.primary),
contentAlignment = Alignment.Center,
) { Text("i", color = Color.White, fontWeight = FontWeight.Black) }
Text("inkwell", fontWeight = FontWeight.Bold, fontSize = 20.sp)
}
Text(if (register) "Sign up" else "Log in", fontWeight = FontWeight.Bold, fontSize = 26.sp)
OutlinedTextField(username, { username = it }, label = { Text("Username") }, modifier = Modifier.fillMaxWidth())
if (register) {
OutlinedTextField(email, { email = it }, label = { Text("Email") }, modifier = Modifier.fillMaxWidth())
Expand Down Expand Up @@ -68,10 +84,10 @@ fun AuthScreen(onDone: () -> Unit) {
}.onFailure { error = it.message }
}
}, modifier = Modifier.fillMaxWidth()) {
Text(if (register) "Create account" else "Enter")
Text(if (register) "Sign up" else "Log in")
}
OutlinedButton(onClick = { register = !register }, modifier = Modifier.fillMaxWidth()) {
Text(if (register) "Have an account?" else "Need an account?")
Text(if (register) "Have an account? Log in" else "Don't have an account? Sign up")
}
}
}
161 changes: 111 additions & 50 deletions android/app/src/main/java/com/inkwell/app/ui/browse/BrowseScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
Expand All @@ -25,17 +29,20 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.inkwell.app.data.Graph
import com.inkwell.app.data.Story
import kotlinx.coroutines.launch
import kotlin.math.abs

@Composable
fun BrowseScreen(onOpen: (String) -> Unit) {
fun BrowseScreen(onOpen: (String) -> Unit, showSearch: Boolean = true) {
var q by remember { mutableStateOf("") }
var stories by remember { mutableStateOf<List<Story>>(emptyList()) }
var loading by remember { mutableStateOf(true) }
Expand All @@ -54,71 +61,125 @@ fun BrowseScreen(onOpen: (String) -> Unit) {

LaunchedEffect(Unit) { reload("") }

Column(Modifier.fillMaxSize().padding(16.dp)) {
Text("Browse", style = MaterialTheme.typography.headlineMedium, fontFamily = FontFamily.Serif)
Text(
"Public shelf from the Inkwell API. Seeded stories appear after the Go server starts.",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.secondary,
modifier = Modifier.padding(top = 4.dp, bottom = 12.dp),
)
OutlinedTextField(
value = q,
onValueChange = {
q = it
reload(it)
},
modifier = Modifier.fillMaxWidth(),
placeholder = { Text("Search titles") },
singleLine = true,
)
val grouped = stories.groupBy { it.genre.ifBlank { "Stories" } }

Column(Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background)) {
Row(
Modifier.fillMaxWidth().background(Color.White).padding(16.dp, 14.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Box(
Modifier
.width(28.dp)
.height(28.dp)
.clip(RoundedCornerShape(6.dp))
.background(MaterialTheme.colorScheme.primary),
contentAlignment = Alignment.Center,
) {
Text("i", color = Color.White, fontWeight = FontWeight.Black, fontSize = 16.sp)
}
Text(" inkwell", fontWeight = FontWeight.Bold, fontSize = 20.sp)
}
if (showSearch) {
OutlinedTextField(
value = q,
onValueChange = {
q = it
reload(it)
},
modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp),
placeholder = { Text("Search") },
singleLine = true,
shape = RoundedCornerShape(24.dp),
)
}
when {
loading -> Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
CircularProgressIndicator()
}
error != null -> Text(error ?: "", color = MaterialTheme.colorScheme.tertiary, modifier = Modifier.padding(top = 16.dp))
stories.isEmpty() -> Text("No stories yet.", modifier = Modifier.padding(top = 16.dp))
else -> LazyColumn(
contentPadding = PaddingValues(vertical = 12.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
items(stories, key = { it.id }) { story ->
StoryRow(story) { onOpen(story.id) }
error != null -> Text(error ?: "", color = MaterialTheme.colorScheme.tertiary, modifier = Modifier.padding(16.dp))
stories.isEmpty() -> Text("No stories yet.", modifier = Modifier.padding(16.dp))
else -> LazyColumn(contentPadding = PaddingValues(bottom = 24.dp)) {
item {
Text("Home", fontWeight = FontWeight.Bold, fontSize = 22.sp, modifier = Modifier.padding(16.dp, 16.dp, 16.dp, 4.dp))
}
item { StoryRail("Trending", stories, onOpen) }
grouped.forEach { (genre, list) ->
item { StoryRail(genre, list, onOpen) }
}
}
}
}
}

@Composable
fun StoryRow(story: Story, onClick: () -> Unit) {
Column(
Modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.background(MaterialTheme.colorScheme.surface)
) {
fun StoryRail(title: String, stories: List<Story>, onOpen: (String) -> Unit) {
Column(Modifier.padding(top = 12.dp)) {
Text(title, fontWeight = FontWeight.Bold, fontSize = 18.sp, modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp))
LazyRow(
contentPadding = PaddingValues(horizontal = 16.dp),
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
items(stories, key = { it.id }) { story ->
StoryCoverCard(story) { onOpen(story.id) }
}
}
}
}

@Composable
fun StoryCoverCard(story: Story, onClick: () -> Unit) {
Column(Modifier.width(120.dp).clickable(onClick = onClick)) {
Box(
Modifier
.fillMaxWidth()
.height(88.dp)
.width(120.dp)
.height(180.dp)
.clip(RoundedCornerShape(4.dp))
.background(coverBrush(story.coverHue)),
) {
Text(
story.genre.ifBlank { "Story" },
color = Color(0xFFF6EFE4),
modifier = Modifier.align(Alignment.BottomStart).padding(12.dp),
style = MaterialTheme.typography.labelMedium,
story.genre.ifBlank { "Story" }.uppercase(),
color = Color.White,
fontSize = 10.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier.align(Alignment.TopStart).padding(8.dp),
)
}
Column(Modifier.padding(12.dp)) {
Text(story.title, style = MaterialTheme.typography.titleLarge, fontFamily = FontFamily.Serif)
Text(
"${story.author.displayName} · ${story.chapterCount} ch.",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.secondary,
story.title,
color = Color.White,
fontWeight = FontWeight.Bold,
fontSize = 13.sp,
modifier = Modifier.align(Alignment.BottomStart).padding(8.dp),
maxLines = 3,
)
Text(story.synopsis, style = MaterialTheme.typography.bodyMedium, maxLines = 3)
}
Text(story.title, fontWeight = FontWeight.Bold, fontSize = 13.sp, maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(top = 6.dp))
Text(story.author.displayName, color = MaterialTheme.colorScheme.secondary, fontSize = 12.sp, maxLines = 1)
}
}

@Composable
fun StoryRow(story: Story, onClick: () -> Unit) {
Row(
Modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.background(Color.White)
.padding(16.dp),
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
Box(
Modifier
.width(72.dp)
.height(108.dp)
.clip(RoundedCornerShape(4.dp))
.background(coverBrush(story.coverHue)),
)
Column(Modifier.weight(1f)) {
Text(story.title, fontWeight = FontWeight.Bold, fontSize = 16.sp)
Text(story.author.displayName, color = MaterialTheme.colorScheme.secondary, fontSize = 13.sp)
Text(story.synopsis, maxLines = 3, overflow = TextOverflow.Ellipsis, color = MaterialTheme.colorScheme.secondary, fontSize = 13.sp, modifier = Modifier.padding(top = 4.dp))
Text("${story.chapterCount} Parts", color = MaterialTheme.colorScheme.secondary, fontSize = 12.sp, modifier = Modifier.padding(top = 6.dp))
}
}
}
Expand All @@ -127,8 +188,8 @@ fun coverBrush(hue: Int): Brush {
val h = abs(hue) % 360
return Brush.linearGradient(
listOf(
Color.hsl(h.toFloat(), 0.32f, 0.26f),
Color.hsl(((h + 46) % 360).toFloat(), 0.38f, 0.14f),
Color.hsl(h.toFloat(), 0.62f, 0.42f),
Color.hsl(((h + 28) % 360).toFloat(), 0.48f, 0.18f),
),
)
}
Loading
Loading