Skip to content

Commit

Permalink
Optimize layouts regarding screen size of both the main screen and th…
Browse files Browse the repository at this point in the history
…e new game screen.

Should match for most circumstances, though fine grained testing seems impossible.
  • Loading branch information
meikpiep committed Nov 27, 2023
1 parent ee50e22 commit 28e5a6c
Show file tree
Hide file tree
Showing 8 changed files with 554 additions and 513 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import androidx.core.view.forEach
import androidx.fragment.app.Fragment
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import org.piepmeyer.gauguin.R
import org.piepmeyer.gauguin.creation.GridDifficultyCalculator
import org.piepmeyer.gauguin.databinding.FragmentNewGameOptionsBinding
import org.piepmeyer.gauguin.preferences.ApplicationPreferencesImpl
import org.piepmeyer.gauguin.options.CurrentGameOptionsVariant
import org.piepmeyer.gauguin.options.DifficultySetting
import org.piepmeyer.gauguin.options.DigitSetting
import org.piepmeyer.gauguin.options.GameVariant
import org.piepmeyer.gauguin.options.GridCageOperation
import org.piepmeyer.gauguin.options.SingleCageUsage
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import org.piepmeyer.gauguin.preferences.ApplicationPreferencesImpl

class GridCellOptionsFragment : Fragment(R.layout.fragment_new_game_options), KoinComponent {
private lateinit var variant: GameVariant
Expand Down Expand Up @@ -77,23 +77,16 @@ class GridCellOptionsFragment : Fragment(R.layout.fragment_new_game_options), Ko
val basicMode = if (tab.position == 0) {
View.VISIBLE
} else {
View.INVISIBLE
View.GONE
}
val advancedMode = if (tab.position != 0) {
View.VISIBLE
} else {
View.INVISIBLE
View.GONE
}

binding.difficultyLabel.visibility = basicMode
binding.difficultyChipGroup.visibility = basicMode
binding.singleCellUsageLabel.visibility = advancedMode
binding.singleCellUsageChipGroup.visibility = advancedMode
binding.operationsLabel.visibility = basicMode
binding.operationsChipGroup.visibility = basicMode
binding.digitsLabel.visibility = advancedMode
binding.digitsChipGroup.visibility = advancedMode
binding.showOperationsSwitch.visibility = advancedMode
binding.newGameOptionsBasicScrollView.visibility = basicMode
binding.newGameOptionsAdvancedScrollView.visibility = advancedMode
}

private fun createSingleCellUsageChips() {
Expand Down
7 changes: 4 additions & 3 deletions gauguin-app/src/main/res/layout-h840dp/activity_newgame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@

<FrameLayout
android:id="@+id/newGameOptions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/newGameOptionsHeading"
/>
app:layout_constraintBottom_toTopOf="@id/startnewgame"
/>

<com.google.android.material.button.MaterialButton
android:id="@+id/startnewgame"
Expand Down
15 changes: 4 additions & 11 deletions gauguin-app/src/main/res/layout-land/activity_newgame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<ScrollView
<FrameLayout
android:id="@+id/newGameOptions"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/startnewgame"
>

<FrameLayout
android:id="@+id/newGameOptions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
/>

</ScrollView>
android:layout_margin="16dp"
/>

<com.google.android.material.button.MaterialButton
android:id="@+id/startnewgame"
Expand Down
Loading

0 comments on commit 28e5a6c

Please sign in to comment.