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

Mvvm/login #3

Open
wants to merge 11 commits into
base: master
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
95 changes: 84 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,86 @@
# Built application files
*.apk
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/
release/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
.idea/misc.xml
.idea/encodings.xml
.idea/codeStyles/Project.xml


# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# Version control
vcs.xml

# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
35 changes: 0 additions & 35 deletions .idea/codeStyles/Project.xml

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

49 changes: 44 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,54 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

packagingOptions {
pickFirst 'META-INF/kotlinx-io.kotlin_module'
pickFirst 'META-INF/atomicfu.kotlin_module'
pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module'
}
}

dependencies {
def koin_version = '2.0.1'
def lifecycle_version = "2.0.0"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.core:core-ktx:1.2.0-alpha01'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.core:core-ktx:1.2.0-alpha02'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha01'

//material design
implementation 'com.google.android.material:material:1.1.0-alpha07'

// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
//retrofit
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
//gson
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'

//coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.0'


// Koin for Android
implementation "org.koin:koin-android:$koin_version"
// Koin AndroidX Scope features
implementation "org.koin:koin-androidx-scope:$koin_version"
// Koin AndroidX ViewModel features
implementation "org.koin:koin-androidx-viewmodel:$koin_version"
}
31 changes: 21 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.incwelltechnology.lms" >
xmlns:tools="http://schemas.android.com/tools"
package="com.incwelltechnology.lms">

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

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" >
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".ui.home.DashboardActivity"
android:label="@string/title_activity_dashboard"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity android:name=".ui.auth.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/com/incwelltechnology/lms/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.incwelltechnology.lms

import android.app.Application
import com.incwelltechnology.lms.module.lmsModule
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin

class App:Application() {
override fun onCreate() {
super.onCreate()
startKoin {
androidLogger()
androidContext(this@App)
modules(lmsModule)
}
}
}
12 changes: 0 additions & 12 deletions app/src/main/java/com/incwelltechnology/lms/MainActivity.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.incwelltechnology.lms.data.model

class BaseResponse<T> {
var status: Boolean = false
var data: T? = null
var error: String = ""
var token: String = ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.incwelltechnology.lms.data.model

data class LoginRequest(val username:String, val password:String)
16 changes: 16 additions & 0 deletions app/src/main/java/com/incwelltechnology/lms/data/model/User.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.incwelltechnology.lms.data.model

data class User(
val full_name : String = "",
val phone_number: String = "",
var email: String= "",
val department: String = "",
var leave_issuer: String ="",
var image: String = "",
var sick_leaves: Int,
var annual_leaves:Int,
var compensation_leaves: Int,
val date_of_birth:String = "",
val joined_date:String = "",
var id:Int=0
)
33 changes: 33 additions & 0 deletions app/src/main/java/com/incwelltechnology/lms/data/network/LmsApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.incwelltechnology.lms.data.network

import com.incwelltechnology.lms.data.model.BaseResponse
import com.incwelltechnology.lms.data.model.LoginRequest
import com.incwelltechnology.lms.data.model.User
import okhttp3.OkHttpClient
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.Body
import retrofit2.http.POST

interface LmsApi {
@POST("login")
suspend fun userLogin(
@Body login: LoginRequest
): Response<BaseResponse<User>>

companion object {
operator fun invoke(networkConnectionInterceptor: NetworkConnectionInterceptor): LmsApi {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai we have decided to create network module isn't it?

val okHttpClient=OkHttpClient.Builder()
.addInterceptor(networkConnectionInterceptor)
.build()

return Retrofit.Builder()
.client(okHttpClient)
.baseUrl("http://192.168.1.100:8000/v1/api/")
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(LmsApi::class.java)
}
}
}
Loading