Skip to content

Commit

Permalink
wip(home): Rework home screen for dynamic content
Browse files Browse the repository at this point in the history
Reworked the home screen to support more dynamic content and layouts.
This includes changes to data structures and UI components to enable greater flexibility.
This work is still in progress and further enhancements are planned.
  • Loading branch information
Mihai-Cristian Condrea committed Dec 5, 2024
1 parent ce4525f commit 2cbaecb
Show file tree
Hide file tree
Showing 18 changed files with 1,083 additions and 877 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.d4rk.englishwithlidia.plus.constants.ui.lessons

object LessonConstants {
const val TYPE_FULL_IMAGE_BANNER = "full_banner"
const val TYPE_BANNER_IMAGE_LOCAL = "banner_image_local"
const val TYPE_ROW_BUTTONS_LOCAL = "row_buttons_local"
const val TYPE_AD_VIEW_BANNER = "ad_view_banner"
const val TYPE_AD_VIEW_BANNER_LARGE = "ad_view_banner_large"
const val TYPE_SQUARE_IMAGE = "square_image"
const val TYPE_TEXT = "text"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.d4rk.englishwithlidia.plus.constants.ui.lessons

object LessonContentTypes {
const val TEXT = "content_text"
const val HEADER = "header"
const val CODE = "content_code"
const val IMAGE = "image"
const val AD_BANNER = "ad_banner"
const val AD_BANNER_FULL = "ad_banner_full"
const val AD_LARGE_BANNER = "ad_large_banner"
const val FULL_IMAGE_BANNER = "full_image_banner"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.d4rk.englishwithlidia.plus.data.model.api

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ApiHomeResponse(
@SerialName("data") val data : List<ApiHomeLessons> = ArrayList()
)

@Serializable
data class ApiHomeLessons(
@SerialName("lesson_id") val lessonId : String = "" ,
@SerialName("lesson_title") val lessonTitle : String = "" ,
@SerialName("lesson_type") val lessonType : String = "" ,
@SerialName("lesson_thumbnail_image_url") var lessonThumbnailImageUrl : String = "" ,
@SerialName("lesson_deep_link_path") val lessonDeepLinkPath : String = "" ,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.d4rk.englishwithlidia.plus.data.model.api

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ApiLessonResponse(
@SerialName("data") val data : List<ApiLesson> = ArrayList()
)

@Serializable
data class ApiLesson(
@SerialName("lesson_title") val lessonTitle : String = "" ,
@SerialName("lesson_content") val lessonContent : List<ApiLessonContent> = emptyList()
)

@Serializable
data class ApiLessonContent(
@SerialName("content_id") val contentId : String = "" ,
@SerialName("content_type") val contentType : String = "" ,
@SerialName("content_text") val contentText : String = "" ,
@SerialName("content_audio_url") val contentAudioUrl : String = "" ,
@SerialName("content_image_url") val contentImageUrl : String = ""
)

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.d4rk.englishwithlidia.plus.data.model.ui.screens.home

data class UiHomeScreen(
val lessons : ArrayList<UiHomeLesson> = ArrayList()
)

data class UiHomeLesson(
val lessonId : String = "" ,
val lessonTitle : String = "" ,
val lessonType : String = "" ,
var lessonThumbnailImageUrl : String = "" ,
val lessonDeepLinkPath : String = "" ,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.d4rk.englishwithlidia.plus.ui.components.buttons

import android.content.Context
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import com.d4rk.englishwithlidia.plus.utils.IntentUtils

@Composable
fun OutlinedUrlButtons(
url : String ,
vectorIcon : ImageVector? = null ,
painterIcon : Painter? = null,
text : Int ,
context : Context ,
modifier : Modifier
) {
OutlinedButton(onClick = {
IntentUtils.openUrl(
context , url = url
)
} , modifier = modifier) {

if (painterIcon != null) {
Icon(
painter = painterIcon ,
contentDescription = null ,
modifier = Modifier.size(ButtonDefaults.IconSize)
)
}
else if (vectorIcon != null) {
Icon(
imageVector = vectorIcon ,
contentDescription = null ,
modifier = Modifier.size(ButtonDefaults.IconSize)
)
}

Spacer(Modifier.size(ButtonDefaults.IconSpacing))
Text(stringResource(id = text))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.d4rk.englishwithlidia.plus.ui.components.dialogs

import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource

@Composable
fun ErrorAlertDialog(
errorMessage : String , onDismiss : () -> Unit
) {
AlertDialog(onDismissRequest = onDismiss ,
title = { Text(text = "Error") } ,
text = { Text(text = errorMessage) } ,
confirmButton = {
TextButton(onClick = onDismiss) {
Text(text = stringResource(id = android.R.string.ok))
}
})
}
Loading

0 comments on commit 2cbaecb

Please sign in to comment.