Skip to content

Commit

Permalink
03/08/2024.
Browse files Browse the repository at this point in the history
  • Loading branch information
youndon committed Aug 3, 2024
1 parent cd1358f commit 80f0f6e
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 175 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ dependencies {
//Koin.
implementation(libs.koin.worker)

//Coil.
//Coil
implementation(libs.coil.compose)
implementation(libs.coil.gif)
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
android:theme="@style/Theme.JetNote"
android:usesCleartextTraffic="false">
android:usesCleartextTraffic="false"
tools:ignore="DataExtractionRules">

<profileable
android:shell="true"
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/city/zouitel/jetnote/NoteApplication.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package city.zouitel.jetnote

import android.app.Application
import android.os.Build
import city.zouitel.audios.di.audioPlayerKoinModule
import city.zouitel.database.di.databaseKoinModule
import city.zouitel.datastore.datastoreKoinModule
Expand All @@ -21,6 +22,8 @@ import city.zouitel.tasks.di.tasksKoinModule
import city.zouitel.widget.di.widgetKoinModule
import coil.ImageLoader
import coil.ImageLoaderFactory
import coil.decode.GifDecoder
import coil.decode.ImageDecoderDecoder
import coil.memory.MemoryCache
import coil.request.CachePolicy
import com.karacca.beetle.Beetle
Expand Down Expand Up @@ -86,6 +89,13 @@ class NoteApplication: Application(), KoinComponent, ImageLoaderFactory {
.weakReferencesEnabled(true)
.build()
}
.components {
if (Build.VERSION.SDK_INT >= 28) {
add(ImageDecoderDecoder.Factory())
} else {
add(GifDecoder.Factory())
}
}
.build()
}
}
4 changes: 1 addition & 3 deletions common/systemDesign/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ dependencies {
//Accompanist.
implementation(libs.accompanist.permissions)
implementation(libs.accompanist.systemuicontroller)
// implementation(libs.accompanist.navigation.animation)
implementation(libs.accompanist.swiperefresh)
// implementation(libs.accompanist.flowlayout)

//Baha-UrlPreview.
implementation(libs.url.preview)

//Balloon.
implementation ("com.github.skydoves:balloon-compose:1.6.4")
implementation (libs.balloon.compose)
}
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ camerax = "1.3.1"
#Coil
coil-compose = "2.7.0"
coil-svg = "2.6.0"
coil-gif = "2.5.0"

#License.
license = "11.1.4"
Expand All @@ -85,6 +86,7 @@ amplituda = "2.2.2"
#android-startup = "1.1.0"
enigma = "1.0.0.8"
media3 = "1.3.1"
balloon-compose = "1.6.4"

[libraries]
#Kotlin.
Expand Down Expand Up @@ -167,6 +169,7 @@ camerax-extensions = { module = "androidx.camera:camera-extensions", version.ref
#Coil.
coil_compose = { module = "io.coil-kt:coil-compose", version.ref = "coil-compose" }
coil_svg = { module = "io.coil-kt:coil-svg", version.ref = "coil-svg" }
coil_gif = { module = "io.coil-kt:coil-gif", version.ref = "coil-gif" }

#License.
licenses = { module = "com.mikepenz:aboutlibraries-compose", version.ref = "license" }
Expand Down Expand Up @@ -195,6 +198,7 @@ audiowaveform = { module = "com.github.lincollincol:compose-audiowaveform", vers
amplituda = { module = "com.github.lincollincol:amplituda", version.ref = "amplituda" }
#android-startup = { module = "io.github.idisfkj:android-startup", version.ref = "android-startup" }
enigma = { module = "gradle.plugin.chrisney:enigma", version.ref = "enigma" }
balloon-compose = { module = "com.github.skydoves:balloon-compose", version.ref = "balloon-compose" }

[bundles]
compose = ["ui", "ui-tooling-preview", "material3"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.HorizontalPager
Expand Down Expand Up @@ -74,7 +75,7 @@ data class MediaScreen(val id: String, val backgroundColor: Int = 0): Screen {
) { index ->
BadgedBox(
modifier = Modifier
.fillMaxWidth()
.fillMaxSize()
.background(Color(backgroundColor)),
badge = {
if (filteredMedias.count() > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package city.zouitel.note.ui.workplace
import android.annotation.SuppressLint
import android.content.Intent
import android.icu.util.Calendar
import android.net.Uri
import android.text.format.DateFormat
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.ContextualFlowRow
Expand All @@ -21,10 +21,7 @@ import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.input.KeyboardActionHandler
import androidx.compose.foundation.text.input.rememberTextFieldState
import androidx.compose.material3.AssistChip
import androidx.compose.material3.AssistChipDefaults
import androidx.compose.material3.Checkbox
import androidx.compose.material3.CheckboxDefaults
Expand Down Expand Up @@ -85,7 +82,7 @@ import city.zouitel.note.ui.bottom_bar.AddEditBottomBar
import city.zouitel.notifications.viewmodel.NotificationScreenModel
import city.zouitel.recoder.ui.RecorderScreen
import city.zouitel.reminder.ui.RemindingNote
import city.zouitel.systemDesign.CommonTextField
import city.zouitel.note.utils.TextField
import city.zouitel.systemDesign.CommonConstants
import city.zouitel.systemDesign.DataStoreScreenModel
import city.zouitel.systemDesign.CommonIcons
Expand Down Expand Up @@ -212,10 +209,7 @@ data class WorkplaceScreen(
rememberLauncherForActivityResult(ActivityResultContracts.PickMultipleVisualMedia()) { uris ->
uris.forEach { uri ->
context.contentResolver.takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
Random.nextLong().let {
mediaModel.addMedia(Media(id = it, path = uri.toString()))
noteAndMediaModel.addNoteAndMedia(NoteAndMedia(id, it))
}
mediaInsert(mediaModel, noteAndMediaModel)
}
}

Expand Down Expand Up @@ -323,8 +317,9 @@ data class WorkplaceScreen(

// The Title.
item {
CommonTextField(
TextField(
state = titleState,
receiver = mediaInsert(mediaModel, noteAndMediaModel),
modifier = Modifier
.height(50.dp)
.focusRequester(focusRequester)
Expand All @@ -336,7 +331,6 @@ data class WorkplaceScreen(
textSize = 24.sp,
textColor = Color(uiState.textColor),
imeAction = ImeAction.Next,
// keyboardAction = KeyboardActions(onNext = { keyboardManager.moveFocus(FocusDirection.Next) })
keyboardAction = {
keyboardManager.moveFocus(FocusDirection.Next)
}
Expand All @@ -345,8 +339,9 @@ data class WorkplaceScreen(

// The Description.
item {
CommonTextField(
TextField(
state = descriptionState,
receiver = mediaInsert(mediaModel, noteAndMediaModel),
modifier = Modifier
.height(200.dp)
.onFocusEvent {
Expand Down Expand Up @@ -520,4 +515,14 @@ data class WorkplaceScreen(
}
}
}

private fun mediaInsert(
mediaModel: MediaScreenModel,
noteAndMediaModel: NoteAndMediaScreenModel
): (Uri) -> Unit = { uri ->
Random.nextLong().let {
mediaModel.addMedia(Media(id = it, path = uri.toString()))
noteAndMediaModel.addNoteAndMedia(NoteAndMedia(id, it))
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package city.zouitel.systemDesign
package city.zouitel.note.utils

import android.net.Uri
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.content.MediaType
import androidx.compose.foundation.content.contentReceiver
import androidx.compose.foundation.content.hasMediaType
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.input.KeyboardActionHandler
import androidx.compose.foundation.text.input.TextFieldState
Expand All @@ -26,8 +29,9 @@ import androidx.compose.ui.unit.dp

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun CommonTextField(
internal fun TextField(
state: TextFieldState,
receiver: (Uri) -> Unit,
modifier: Modifier,
placeholder: String = "...",
textSize: TextUnit = TextUnit(19f, TextUnitType.Sp),
Expand All @@ -50,7 +54,17 @@ fun CommonTextField(
modifier = modifier
.fillMaxWidth()
.padding(10.dp)
.background(Color.Transparent),
.background(Color.Transparent)
.contentReceiver { content ->
if(content.hasMediaType(MediaType.Image)) {
val data = content.clipEntry.clipData
for (index in 0 until data.itemCount) {
val item = data.getItemAt(index)
receiver.invoke(item.uri)
}
}
content
},
textStyle = TextStyle(
fontSize = textSize,
fontWeight = FontWeight.Normal,
Expand All @@ -59,7 +73,7 @@ fun CommonTextField(
),
keyboardOptions = KeyboardOptions(
capitalization = KeyboardCapitalization.Sentences,
autoCorrect = false,
autoCorrectEnabled = false,
keyboardType = KeyboardType.Text,
imeAction = imeAction
),
Expand Down
Loading

0 comments on commit 80f0f6e

Please sign in to comment.