-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 46e10eb
Showing
54 changed files
with
1,296 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'org.jetbrains.kotlin.android' | ||
id 'maven-publish' | ||
} | ||
|
||
ext { | ||
compose_version = '1.3.2' | ||
version_hilt_navigation = "1.0.0-rc01" | ||
coroutines_version = "1.5.1" | ||
|
||
} | ||
android { | ||
namespace 'com.codercamp.startabview' | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
minSdk 21 | ||
targetSdk 33 | ||
versionCode = 1 | ||
versionName = "1.0.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled 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 { | ||
compose true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion compose_version | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'com.google.android.material:material:1.7.0' | ||
implementation 'androidx.compose.material:material:1.3.1' | ||
|
||
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("io.coil-kt:coil-compose:2.2.2") | ||
implementation("io.coil-kt:coil-svg:2.2.2") | ||
implementation "androidx.navigation:navigation-compose:2.6.0-alpha04" | ||
implementation("androidx.compose.material:material:1.3.1") | ||
def accompanist_version = "0.28.0" | ||
implementation "com.google.accompanist:accompanist-pager:$accompanist_version" // Pager | ||
implementation "com.google.accompanist:accompanist-pager-indicators:$accompanist_version" // Pager Indicator | ||
|
||
} | ||
afterEvaluate { | ||
publishing { | ||
publications { | ||
release(MavenPublication) { | ||
from components.release | ||
groupId = 'com.github.shamimcse1' | ||
artifactId = 'star-tab-view-compose' | ||
version = '1.0.0' | ||
} | ||
} | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
StarTabView/src/androidTest/java/com/codercamp/startabview/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.codercamp.startabview | ||
|
||
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("com.codercamp.startabview.test", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
16 changes: 16 additions & 0 deletions
16
StarTabView/src/main/java/com/codercamp/startabview/StarTabContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.codercamp.startabview | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.google.accompanist.pager.ExperimentalPagerApi | ||
import com.google.accompanist.pager.HorizontalPager | ||
import com.google.accompanist.pager.PagerState | ||
|
||
|
||
@OptIn(ExperimentalPagerApi::class) | ||
@Composable | ||
fun StarTabsContent(tabList: List<StarTabItem>, pagerState: PagerState) { | ||
HorizontalPager( | ||
count = tabList.size,state = pagerState) { page -> | ||
tabList[page].screen() | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
StarTabView/src/main/java/com/codercamp/startabview/StarTabItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.codercamp.startabview | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
typealias ComposableFun = @Composable () -> Unit | ||
|
||
data class StarTabItem( | ||
var title: String, | ||
var screen: ComposableFun | ||
) |
34 changes: 34 additions & 0 deletions
34
StarTabView/src/main/java/com/codercamp/startabview/StarTabLayout.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.codercamp.startabview | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
|
||
import com.google.accompanist.pager.ExperimentalPagerApi | ||
import com.google.accompanist.pager.rememberPagerState | ||
|
||
|
||
@OptIn(ExperimentalPagerApi::class) | ||
@Composable | ||
fun StarTabLayout( | ||
modifier: Modifier = Modifier, | ||
tabList: List<StarTabItem>, | ||
tabColor: Color = Color.White, | ||
tabIndicatorColor: Color = Color.Blue, | ||
) { | ||
|
||
val pagerState = rememberPagerState(initialPage = 0) | ||
|
||
Column( | ||
modifier = modifier.background(tabColor) | ||
) { | ||
StarTabs(pagerState = pagerState, tabList = tabList, indicatorColor = tabIndicatorColor) | ||
StarTabsContent( | ||
pagerState = pagerState, | ||
tabList = tabList | ||
) | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
StarTabView/src/main/java/com/codercamp/startabview/StarTabs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.codercamp.startabview | ||
|
||
import androidx.compose.material.Tab | ||
import androidx.compose.material.TabRow | ||
import androidx.compose.material.TabRowDefaults | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.google.accompanist.pager.ExperimentalPagerApi | ||
import com.google.accompanist.pager.PagerState | ||
import com.google.accompanist.pager.pagerTabIndicatorOffset | ||
import kotlinx.coroutines.launch | ||
|
||
|
||
@OptIn(ExperimentalPagerApi::class) | ||
@ExperimentalPagerApi | ||
@Composable | ||
fun StarTabs( | ||
pagerState: PagerState, | ||
tabList: List<StarTabItem>, | ||
indicatorColor: Color = Color.Black, | ||
) { | ||
|
||
val scope = rememberCoroutineScope() | ||
|
||
TabRow( | ||
selectedTabIndex = pagerState.currentPage, | ||
backgroundColor = Color.White, | ||
contentColor = Color.White, | ||
indicator = { tabPositions -> | ||
TabRowDefaults.Indicator( | ||
Modifier.pagerTabIndicatorOffset(pagerState, tabPositions), | ||
height = 2.dp, | ||
color = indicatorColor | ||
) | ||
} | ||
) { | ||
|
||
tabList.forEachIndexed { index, _ -> | ||
Tab( | ||
text = { | ||
Text( | ||
tabList[index].title, | ||
color = if (pagerState.currentPage == index) Color.Black else Color.Black, | ||
style = TextStyle(fontSize = 14.sp, fontWeight = FontWeight.Bold) | ||
) | ||
}, | ||
selected = pagerState.currentPage == index, | ||
onClick = { | ||
scope.launch { | ||
pagerState.animateScrollToPage(index) | ||
} | ||
} | ||
) | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
StarTabView/src/test/java/com/codercamp/startabview/ExampleUnitTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.codercamp.startabview | ||
|
||
import org.junit.Test | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
class ExampleUnitTest { | ||
@Test | ||
fun addition_isCorrect() { | ||
assertEquals(4, 2 + 2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Oops, something went wrong.