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

Master #1

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
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
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

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

6 changes: 6 additions & 0 deletions .idea/compiler.xml

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

20 changes: 20 additions & 0 deletions .idea/gradle.xml

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

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

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

9 changes: 9 additions & 0 deletions .idea/misc.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
# auth-mobile-app

Hello there, your task is to convert the following figma design into a mobile app:
Android application built using Kotlin as a task from [Intern2Grow](https://intern2grow.vercel.app/)

https://www.figma.com/file/8c8KBj7I6VW5sbuJNRbF7E/auth-screens?type=design&node-id=0%3A1&mode=design&t=yzOIpKZWeIWjbMO3-1

Then use one of the following APIs to implement authentication:
![design-1700055357703](https://github.com/mahmoodawd/auth-mobile-app/assets/63718329/d599d253-84c9-4f81-b0cb-b31f6ebd925f)

https://dummyjson.com/docs/auth

https://reqres.in/

So make sure that you have covered all the following tasks:

- design login, register and profile screens.
- implement navigation between screens.
- implement login, register, remember me and log out functionalities.
- display user details in profile screen.
## Features
- Registration and signup functionalities using [DummyJsonAPI](https://dummyjson.com/docs/auth)
- Display Profile details.
- Remember me feature for auto login.

That's all, fork the repository and start working on it.
## Libraries and Technologies

Best of luck.
### ViewBinding
### Manual Dependency Injection
### Navigation Component
### Retrofit for Networking
### Coroutines
### DataStore to save user credentials locally
### Kotlin Serialization
### Image Loading with Glide






## Contact

For any inquiries or questions, you can reach me at [<img align="center" src="https://img.shields.io/badge/gmail-%23FF0000?style=plastic&logo=gmail&logoColor=white"/>](mailto:mahmooodawd@gmail.com).
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
85 changes: 85 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("androidx.navigation.safeargs.kotlin")
id("org.jetbrains.kotlin.plugin.serialization")
kotlin("kapt")
}

android {
namespace = "dev.awd.auth"
compileSdk = 34

defaultConfig {
applicationId = "dev.awd.auth"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
dataBinding = true
viewBinding = true
}
}

dependencies {

implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.9.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.2")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")

//Navigation
implementation("androidx.navigation:navigation-ui-ktx:2.7.5")
implementation("androidx.navigation:navigation-fragment-ktx:2.7.5")

//Coroutines
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")

//Retrofit
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation("com.google.code.gson:gson:2.10.1")
implementation("com.squareup.retrofit2:converter-moshi:2.9.0")
implementation("com.squareup.moshi:moshi-kotlin:1.14.0")

//Glide
implementation("com.github.bumptech.glide:glide:4.16.0")

//DataStore & Serialization
implementation("androidx.datastore:datastore:1.0.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")

testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}

kapt {
correctErrorTypes = true
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
24 changes: 24 additions & 0 deletions app/src/androidTest/java/dev/awd/auth/ExampleInstrumentedTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.awd.auth

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("dev.awd.auth", appContext.packageName)
}
}
32 changes: 32 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

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

<application
android:name=".AuthApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Auth"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.Auth"
android:windowSoftInputMode="stateVisible|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</manifest>
17 changes: 17 additions & 0 deletions app/src/main/java/dev/awd/auth/AuthApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package dev.awd.auth

import android.app.Application
import dev.awd.auth.di.AppModule
import dev.awd.auth.di.AppModuleImpl

class AuthApplication : Application() {
companion object {
lateinit var appModule: AppModule
}

override fun onCreate() {
super.onCreate()
appModule = AppModuleImpl(applicationContext)
}

}
70 changes: 70 additions & 0 deletions app/src/main/java/dev/awd/auth/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package dev.awd.auth

import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsAnimationCompat
import androidx.core.view.WindowInsetsCompat
import dev.awd.auth.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding

companion object {
private const val TAG = "MainActivity"
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
}

private fun animateKeyboard() {
val view = binding.navHostFragment
ViewCompat.setWindowInsetsAnimationCallback(
view,
object : WindowInsetsAnimationCompat.Callback(
DISPATCH_MODE_STOP
) {
var startBottom = 0f
var endBottom = 0f

override fun onPrepare(
animation: WindowInsetsAnimationCompat
) {
startBottom = view.bottom.toFloat()
Log.d(TAG, "onPrepare Animation: $startBottom")
}

override fun onStart(
animation: WindowInsetsAnimationCompat,
bounds: WindowInsetsAnimationCompat.BoundsCompat
): WindowInsetsAnimationCompat.BoundsCompat {
// Record the position of the view after the IME transition.
endBottom = view.bottom.toFloat()
Log.d(TAG, "onStart Animation at :$endBottom")
return bounds
}

override fun onProgress(
insets: WindowInsetsCompat,
runningAnimations: MutableList<WindowInsetsAnimationCompat>
): WindowInsetsCompat {
val imeAnimation = runningAnimations.find {
Log.d(TAG, "onProgress Animation")
it.typeMask and WindowInsetsCompat.Type.ime() != 0
} ?: return insets

view.translationY =
(startBottom - endBottom) * (1 - imeAnimation.interpolatedFraction)

return insets
}
}

)
}

}
8 changes: 8 additions & 0 deletions app/src/main/java/dev/awd/auth/data/ApiResponse.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.awd.auth.data

sealed class ApiResponse {

class Success<T>(val data: T) : ApiResponse()
class Failure(val error: String) : ApiResponse()
data object Loading : ApiResponse()
}
Loading