Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
meikpiep committed Feb 20, 2025
1 parent b1ac5b0 commit 54b991b
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class MainActivity : AppCompatActivity() {
innerPadding.right,
0,
)
insets

WindowInsetsCompat.CONSUMED
}

ViewCompat.setOnApplyWindowInsetsListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package org.piepmeyer.gauguin.ui.newgame
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.commit
import androidx.lifecycle.ViewModelProvider
import com.google.android.material.bottomsheet.BottomSheetBehavior
Expand All @@ -17,11 +19,11 @@ class NewGameActivity : AppCompatActivity() {
private lateinit var viewModel: NewGameViewModel

public override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState)

val binding = ActivityNewgameBinding.inflate(layoutInflater)
enableEdgeToEdge()
setContentView(binding.root)

activityUtils.configureTheme(this)
Expand All @@ -46,8 +48,39 @@ class NewGameActivity : AppCompatActivity() {
val bottomSheetBehavior = BottomSheetBehavior.from(it)
bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
}

ViewCompat.setOnApplyWindowInsetsListener(
binding.newGameGridShapeOptions,
) { v, insets ->
val innerPadding =
insets.getInsets(
WindowInsetsCompat.Type.systemBars()
or WindowInsetsCompat.Type.displayCutout(),
)

if (hasVerticalBaseLayout(binding)) {
v.setPadding(
innerPadding.left,
innerPadding.top,
innerPadding.right,
0,
)
} else {
v.setPadding(
innerPadding.left,
innerPadding.top,
0,
innerPadding.bottom,
)
}

WindowInsetsCompat.CONSUMED
}
}

private fun hasVerticalBaseLayout(binding: ActivityNewgameBinding): Boolean =
binding.root.tag == "newGameLayoutDefault" || binding.root.tag == "newGameLayoutW600"

private fun startNewGame() {
val gridAlreadyCalculated = viewModel.startNewGame()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:tag="newGameLayoutH840"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.newgame.NewGameActivity" >
Expand Down
1 change: 1 addition & 0 deletions gauguin-app/src/main/res/layout-land/activity_newgame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:tag="newGameLayoutLandscape"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.newgame.NewGameActivity" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:tag="newGameLayoutW600Landscape"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.newgame.NewGameActivity" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:tag="newGameLayoutW600"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.newgame.NewGameActivity" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:tag="newGameLayoutW840Landscape"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.newgame.NewGameActivity" >
Expand Down
1 change: 1 addition & 0 deletions gauguin-app/src/main/res/layout/activity_newgame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:tag="newGameLayoutDefault"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
Expand Down

0 comments on commit 54b991b

Please sign in to comment.