Skip to content

Commit

Permalink
feat
Browse files Browse the repository at this point in the history
  • Loading branch information
aikrq committed Dec 2, 2024
1 parent d058a33 commit 79c1830
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void onCreate(Bundle savedInstanceState) {
mWizardLayout.setSteps(steps);

setContentView(mWizardLayout.getView(), new ViewGroup.LayoutParams(-1, -1));
setDecorFitsSystemWindows(getWindow(), false);
// setDecorFitsSystemWindows(getWindow(), false);

if (mWizardLayout.getSteps().isEmpty()) {
mWizardLayout.addStep(new BasicWizardStep());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface IWizardLayout {
boolean presentStep(WizardParams params);
boolean addStep(WizardStep step, int position);
void removeStep(WizardStep step, boolean immediate);
void closeLastStep();
boolean closeLastStep();
void setSteps(List<WizardStep> steps);
List<WizardStep> getSteps();
boolean onBackPressed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,12 @@ public void removeStep(WizardStep step, boolean immediate) {
}

@Override
public void closeLastStep() {
public boolean closeLastStep() {
WizardStep step = getLastStep();
if (step != null && step.closeLastStep()) return;
if (step != null && step.closeLastStep()) {
return false;
}

WizardStep currentStep = getLastStep();
WizardStep previousStep = null;
if (steps.size() > 1) {
Expand Down Expand Up @@ -143,7 +146,10 @@ public void closeLastStep() {
} else {
removeStepInternal(currentStep, false);
setVisibility(View.GONE);
return false;
}

return true;
}

@Override
Expand Down Expand Up @@ -179,8 +185,7 @@ public boolean onBackPressed() {

if (lastStep != null && lastStep.onBackPressed()) {
if (!steps.isEmpty()) {
closeLastStep();
return true;
return closeLastStep();
}
}

Expand Down Expand Up @@ -239,11 +244,11 @@ private void presentStepInternalRemoveOld(boolean removeLast, WizardStep step) {
parent.removeViewInLayout(step.getStepView());
} catch (Exception e) {
e.printStackTrace();
try {
parent.removeView(step.getStepView());
} catch (Exception e2) {
e2.printStackTrace();
}
// try {
// parent.removeView(step.getStepView());
// } catch (Exception e2) {
// e2.printStackTrace();
// }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mod.remaker.activity.projectwizard.model;

import static pro.sketchware.utility.UI.addSystemWindowInsetToPadding;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -35,8 +37,10 @@ public final View onCreateView(Context context) {
private void configureStep(WizardStepBinding binding) {
Context ctx = binding.getRoot().getContext();
binding.toolbar.setNavigationOnClickListener(v -> parentLayout.onBackPressed());
binding.toolbar.setTitle(getTitle(ctx));
binding.title.setText(getTitle(ctx));
binding.message.setText(getSubtitle(ctx));

// addSystemWindowInsetToPadding(binding.getRoot(), false, true, false, true);
}

public View getContentView(LayoutInflater inflater, ViewGroup container) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/pro/sketchware/utility/UI.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void addSystemWindowInsetToPadding(
ViewCompat.setOnApplyWindowInsetsListener(
view,
(v, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.ime());
view.setPadding(
initialLeft + (left ? insets.left : 0),
initialTop + (top ? insets.top : 0),
Expand Down
106 changes: 50 additions & 56 deletions app/src/main/res/layout/wizard_step.xml
Original file line number Diff line number Diff line change
@@ -1,62 +1,56 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:transitionGroup="true">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:elevation="0dp"
app:liftOnScroll="false"
app:liftOnScrollColor="@android:color/transparent">

<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/collapsingToolbarLayoutLargeSize"
android:fitsSystemWindows="true"
app:collapsedTitleTextColor="?attr/colorOnSurface"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:expandedTitleMarginStart="24dp"
app:expandedTitleTextColor="?attr/colorOnSurface">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginStart="4dp"
app:layout_collapseMode="pin"
app:navigationIcon="?attr/homeAsUpIndicator"
app:navigationIconTint="?attr/colorOnSurface" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:textAppearance="?attr/textAppearanceBodyMedium" />

<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingBottom="16dp"
android:paddingTop="16dp" />

</LinearLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
android:layout_marginStart="4dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navigationIcon="?attr/homeAsUpIndicator"
app:navigationIconTint="?attr/colorOnSurface" />

<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="112dp"
android:ellipsize="end"
android:maxLines="2"
android:textAppearance="?attr/textAppearanceHeadlineMedium"
android:textColor="?attr/colorOnSurface"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar" />

<TextView
android:id="@+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:textAppearance="?attr/textAppearanceBodyMedium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/title" />

<FrameLayout
android:id="@+id/container"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="24dp"
android:layout_marginTop="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/message" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 79c1830

Please sign in to comment.