Skip to content

Commit

Permalink
Merge pull request #115 from VictorKabata/fix-publishing-to-maven
Browse files Browse the repository at this point in the history
Update gradle plugin
  • Loading branch information
VictorKabata authored Aug 13, 2024
2 parents 7ecb21f + 12182ff commit 93a320c
Show file tree
Hide file tree
Showing 49 changed files with 712 additions and 688 deletions.
8 changes: 5 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[*.{kt,kts}]
disabled_rules = import-ordering, experimental:argument-list-wrapping, package-name
insert_final_newline = true
root = true

[*]
ktlint_standard_final-newline = disabled
ktlint_function_naming_ignore_when_annotated_with = Composable
22 changes: 11 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ jobs:
steps:

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'

- name: Make gradle executable
run: chmod +x ./gradlew
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Build with gradle
run: ./gradlew :daraja:build --stacktrace
Expand All @@ -32,16 +32,16 @@ jobs:
steps:

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'

- name: Make gradle executable
run: chmod +x ./gradlew
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Execute unit tests
run: ./gradlew :daraja:allTests --stacktrace
Expand All @@ -50,7 +50,7 @@ jobs:
run: ./gradlew :daraja:koverHtmlReport --stacktrace

- name: Upload test report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: unit_tests_report.html
path: daraja/build/reports/kover/html/
14 changes: 7 additions & 7 deletions .github/workflows/maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ jobs:
steps:

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'

- name: Make gradle executable
run: chmod +x ./gradlew
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Check for release dependencies
run: ./gradlew :daraja:dependencyUpdates -Drevision=release -DoutputFormatter=html -DreportfileName=dependencies_report --stacktrace

- name: Upload dependencies report artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Dependency Report
path: build/reports/dependencies_report.html
path: daraja/build/reports/dependencies_report.html
5 changes: 1 addition & 4 deletions .github/workflows/publish_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
uses: gradle/actions/setup-gradle@v4

- name: Execute unit tests
run: ./gradlew :daraja:check --stacktrace
run: ./gradlew :daraja:allTests --stacktrace

deploy-android:
name: 🚀 Sign and Publish Android Library
Expand All @@ -66,9 +66,6 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Clean & Build
run: ./gradlew :daraja:clean :daraja:build --stacktrace

- name: Sign and Publish Android Library
run: ./gradlew :daraja:publishAndroidReleasePublicationToSonatypeRepository --max-workers 1 --stacktrace
env:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish_swift_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

jobs:
build:
name: 🔨 Build
runs-on: macos-latest
steps:
- name: Checkout
Expand All @@ -35,6 +36,7 @@ jobs:
retention-days: 1

push:
name: 📤 Push to Swift Repo
needs: build
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion app-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ android {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
"proguard-rules.pro",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.koin.core.context.startKoin
import org.koin.core.logger.Level

class DarajaKmpApplication : Application() {

override fun onCreate() {
super.onCreate()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ import com.vickbt.darajakmp.Daraja
import org.koin.androidx.viewmodel.dsl.viewModelOf
import org.koin.dsl.module

val presentationModule = module {
val presentationModule =
module {

single {
Daraja.Builder()
.setConsumerKey("zg1m1CbMGx8E2BqVThHIJHFMWSnVJ4XA")
.setConsumerSecret("z4CAY2TUw6rprEvy")
.setPassKey("bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919")
.isSandbox()
.build()
}
single {
Daraja.Builder()
.setConsumerKey("zg1m1CbMGx8E2BqVThHIJHFMWSnVJ4XA")
.setConsumerSecret("z4CAY2TUw6rprEvy")
.setPassKey("bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919")
.isSandbox()
.build()
}

viewModelOf(::HomeViewModel)
}
viewModelOf(::HomeViewModel)
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MainActivity : ComponentActivity() {
DarajaKmpTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
color = MaterialTheme.colorScheme.background,
) {
HomeScreen()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,40 +76,44 @@ fun HomeScreen(viewModel: HomeViewModel = get()) {
val (card, button) = createRefs()

ElevatedCard(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(.35f)
.padding(horizontal = 24.dp)
.constrainAs(card) {
top.linkTo(parent.top)
bottom.linkTo(parent.bottom)
start.linkTo(parent.start)
end.linkTo(parent.end)
},
shape = RoundedCornerShape(6.dp)
modifier =
Modifier
.fillMaxWidth()
.fillMaxHeight(.35f)
.padding(horizontal = 24.dp)
.constrainAs(card) {
top.linkTo(parent.top)
bottom.linkTo(parent.bottom)
start.linkTo(parent.start)
end.linkTo(parent.end)
},
shape = RoundedCornerShape(6.dp),
) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 20.dp),
verticalArrangement = Arrangement.spacedBy(
space = 24.dp,
alignment = Alignment.CenterVertically
)
modifier =
Modifier
.fillMaxSize()
.padding(horizontal = 20.dp),
verticalArrangement =
Arrangement.spacedBy(
space = 24.dp,
alignment = Alignment.CenterVertically,
),
) {
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
value = amount.toString(),
onValueChange = { amount = it.toInt() },
singleLine = true,
maxLines = 1,
textStyle = TextStyle(
fontSize = 20.sp,
color = MaterialTheme.colorScheme.onBackground
),
textStyle =
TextStyle(
fontSize = 20.sp,
color = MaterialTheme.colorScheme.onBackground,
),
label = { Text(text = "Amount") },
colors = TextFieldDefaults.outlinedTextFieldColors(focusedBorderColor = MaterialTheme.colorScheme.primary),
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number)
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number),
)

OutlinedTextField(
Expand All @@ -118,26 +122,28 @@ fun HomeScreen(viewModel: HomeViewModel = get()) {
onValueChange = { it.let { phoneNumber = it } },
singleLine = true,
maxLines = 1,
textStyle = TextStyle(
fontSize = 20.sp,
color = MaterialTheme.colorScheme.onBackground
),
textStyle =
TextStyle(
fontSize = 20.sp,
color = MaterialTheme.colorScheme.onBackground,
),
label = { Text(text = "Phone Number") },
colors = TextFieldDefaults.outlinedTextFieldColors(focusedBorderColor = MaterialTheme.colorScheme.primary),
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Phone)
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Phone),
)
}
}

FloatingActionButton(
modifier = Modifier
.size(64.dp)
.constrainAs(button) {
top.linkTo(card.bottom)
bottom.linkTo(card.bottom)
start.linkTo(card.start)
end.linkTo(card.end)
},
modifier =
Modifier
.size(64.dp)
.constrainAs(button) {
top.linkTo(card.bottom)
bottom.linkTo(card.bottom)
start.linkTo(card.start)
end.linkTo(card.end)
},
shape = CircleShape,
containerColor = colorResource(id = R.color.theme_color),
contentColor = Color.White,
Expand All @@ -149,14 +155,14 @@ fun HomeScreen(viewModel: HomeViewModel = get()) {
phoneNumber = phoneNumber,
transactionDesc = "Mpesa payment",
callbackUrl = "https://mydomain.com/path",
accountReference = "Daraja KMP Android"
accountReference = "Daraja KMP Android",
)
}
},
) {
Icon(
modifier = Modifier.size(28.dp),
painter = painterResource(id = R.drawable.ic_payment),
contentDescription = "Pay"
contentDescription = "Pay",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch

class HomeViewModel constructor(private val daraja: Daraja) : ViewModel() {

private val _mpesaResponse = MutableStateFlow<DarajaResult<MpesaExpressResponse>?>(null)
val mpesaResponse get() = _mpesaResponse.asStateFlow()

Expand All @@ -36,16 +35,17 @@ class HomeViewModel constructor(private val daraja: Daraja) : ViewModel() {
phoneNumber: String,
transactionDesc: String,
callbackUrl: String,
accountReference: String
accountReference: String,
) = viewModelScope.launch {
val response = daraja.mpesaExpress(
businessShortCode = businessShortCode.trim(),
amount = amount,
phoneNumber = phoneNumber.trim(),
transactionDesc = transactionDesc,
callbackUrl = callbackUrl.trim(),
accountReference = accountReference.trim()
)
val response =
daraja.mpesaExpress(
businessShortCode = businessShortCode.trim(),
amount = amount,
phoneNumber = phoneNumber.trim(),
transactionDesc = transactionDesc,
callbackUrl = callbackUrl.trim(),
accountReference = accountReference.trim(),
)

_mpesaResponse.value = response
}
Expand Down
Loading

0 comments on commit 93a320c

Please sign in to comment.