Skip to content
Open
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
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 37 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'
}

android {
Expand Down Expand Up @@ -44,13 +46,31 @@ android {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation "com.google.dagger:hilt-android:2.44"
kapt "com.google.dagger:hilt-compiler:2.44"

implementation('androidx.core:core-ktx:1.10.0') {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
}
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.7.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.compose.material3:material3:1.0.0-alpha11'
Expand All @@ -60,4 +80,18 @@ dependencies {
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"

implementation("androidx.lifecycle:lifecycle-runtime-compose:2.6.1")
implementation "com.google.accompanist:accompanist-navigation-animation:0.30.0"

implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.2'
implementation("io.coil-kt:coil-compose:2.2.2")
implementation("io.coil-kt:coil-gif:2.2.2")
}

kapt {
correctErrorTypes true
}
13 changes: 10 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
package="com.example.toptracer">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".MyApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand All @@ -11,17 +15,20 @@
android:supportsRtl="true"
android:theme="@style/Theme.TopTracer"
tools:targetApi="31">

<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.TopTracer">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>

</application>

</manifest>
</manifest>
22 changes: 22 additions & 0 deletions app/src/main/java/com/example/toptracer/AppModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.toptracer

import com.example.toptracer.data.GifRepository
import com.example.toptracer.data.GiphyApiService
import com.example.toptracer.data.RetrofitInstance
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object AppModule {
@Provides
@Singleton
fun provideGiphyApiService(): GiphyApiService = RetrofitInstance.giphyApiService

@Provides
@Singleton
fun provideGifRepository(giphyApiService: GiphyApiService): GifRepository = GifRepository(giphyApiService)
}
7 changes: 7 additions & 0 deletions app/src/main/java/com/example/toptracer/Application.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.toptracer

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class MyApplication : Application()
106 changes: 3 additions & 103 deletions app/src/main/java/com/example/toptracer/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,117 +3,17 @@ package com.example.toptracer
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.toptracer.helpers.TopTracerPasswordTransformation
import com.example.toptracer.ui.theme.TopTracerTheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
TopTracerTheme {
// A surface container using the 'background' color from the theme
Surface(

modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,

) {
LoginScreen()
}
TopTracer()
}
}
}
}

@Composable
fun LoginScreen() {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
verticalArrangement = Arrangement.Center
) {
var username by remember { mutableStateOf("") }
var password by remember { mutableStateOf("") }

Row(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 8.dp),
verticalAlignment = Alignment.CenterVertically

) {
Text(
text = "Username",
modifier = Modifier.weight(1f)
)
TextField(
value = username,
onValueChange = { username = it },
colors = TextFieldDefaults.textFieldColors(containerColor = Color.Transparent),
modifier = Modifier.weight(3f),
)
}

Row(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 8.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "Password",
modifier = Modifier.weight(1f)
)
TextField(
value = password,
onValueChange = { password = it },
visualTransformation = TopTracerPasswordTransformation(),
singleLine = true,
colors = TextFieldDefaults.textFieldColors(containerColor = Color.Transparent),
modifier = Modifier
.weight(3f)
)
}
Row(

modifier = Modifier
.fillMaxWidth(),

) {
Text(
text = "Forgot Password",
modifier = Modifier
.weight(1f)
.wrapContentSize(Alignment.Center)
.clickable {}
)

Text(
text = "Login",
modifier = Modifier
.weight(1f)
.wrapContentSize(Alignment.Center)
.clickable {}
)
}
}
}


@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
TopTracerTheme {
LoginScreen()
}
}
82 changes: 82 additions & 0 deletions app/src/main/java/com/example/toptracer/TopTracer.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.example.toptracer

import LoginViewModel
import androidx.compose.animation.*
import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.lifecycle.viewmodel.compose.viewModel
import com.example.toptracer.ui.LoginScreen
import com.example.toptracer.ui.WelcomeScreen
import com.example.toptracer.viewmodel.WelcomeViewModel
import com.google.accompanist.navigation.animation.AnimatedNavHost
import com.google.accompanist.navigation.animation.composable
import com.google.accompanist.navigation.animation.rememberAnimatedNavController

enum class AppSection {
Login, Welcome
}

@OptIn(ExperimentalAnimationApi::class)
@Composable
fun TopTracer(modifier: Modifier = Modifier) {
val navController = rememberAnimatedNavController()
val loginViewModel = viewModel<LoginViewModel>()
val welcomeViewModel = viewModel<WelcomeViewModel>()

Surface(
modifier.fillMaxWidth()
) {
AnimatedNavHost(
navController = navController,
startDestination = AppSection.Login.name
) {
composable(
route = AppSection.Login.name,
enterTransition = {
slideInHorizontally(
initialOffsetX = { -it },
animationSpec = tween(durationMillis = 300)
) + fadeIn(animationSpec = tween(durationMillis = 300))
},
exitTransition = {
slideOutHorizontally(
targetOffsetX = { -it },
animationSpec = tween(durationMillis = 300)
) + fadeOut(animationSpec = tween(durationMillis = 300))
},
) {
LoginScreen(
loginViewModel = loginViewModel,
onLoginSuccess = {
navController.navigate(AppSection.Welcome.name)
}
)
}
composable(
route = AppSection.Welcome.name,
enterTransition = {
slideInHorizontally(
initialOffsetX = { it },
animationSpec = tween(durationMillis = 300)
) + fadeIn(animationSpec = tween(durationMillis = 300))
},
exitTransition = {
slideOutHorizontally(
targetOffsetX = { it },
animationSpec = tween(durationMillis = 300)
) + fadeOut(animationSpec = tween(durationMillis = 300))
},
) {
WelcomeScreen(
viewModel = welcomeViewModel,
onLogoutClicked = {
navController.navigate(AppSection.Login.name)
}
)
}
}
}
}
Loading