Skip to content

Commit

Permalink
feat: animation on step state changed
Browse files Browse the repository at this point in the history
  • Loading branch information
aikrq committed Dec 4, 2024
1 parent ea20f86 commit cf9f835
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import android.view.ViewGroup;
import android.widget.FrameLayout;

import androidx.transition.TransitionManager;

import com.google.android.material.transition.MaterialSharedAxis;

import mod.remaker.activity.projectwizard.ProjectWizardActivity;

import pro.sketchware.R;
Expand Down Expand Up @@ -50,6 +54,8 @@ public boolean presentStep(IWizardLayout.WizardParams params) {
wrappedView.setLayoutParams(new LayoutParams(-1, -1));
steps.add(step);

buildLayoutAnimation(true);

FrameLayout temp = containerView;
containerView = containerViewBack;
containerViewBack = temp;
Expand Down Expand Up @@ -116,6 +122,8 @@ public boolean closeLastStep() {
stepView = previousStep.onCreateView(activity);
}

buildLayoutAnimation(false);

containerView.setVisibility(View.VISIBLE);
removeViewFromParent(stepView);
containerView.addView(stepView);
Expand Down Expand Up @@ -205,10 +213,7 @@ public void bringToFront(int position) {
}

public WizardStep getLastStep() {
if (steps.isEmpty()) {
return null;
}
return steps.get(steps.size() - 1);
return !steps.isEmpty() ? steps.get(steps.size() - 1) : null;
}

private void presentStepInternalRemoveOld(boolean removeLast, WizardStep step) {
Expand Down Expand Up @@ -286,4 +291,9 @@ private void checkStepViewBackground(View view) {
view.setBackgroundColor(ThemeUtils.getColor(view, R.attr.colorSurface));
}
}

private void buildLayoutAnimation(final boolean open) {
MaterialSharedAxis transition = new MaterialSharedAxis(MaterialSharedAxis.X, open);
TransitionManager.beginDelayedTransition(this, transition);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ public boolean onBackPressed() {
}

public Activity getParentActivity() {
if (parentLayout != null) {
return parentLayout.getParentActivity();
}
return null;
return parentLayout != null ? parentLayout.getParentActivity() : null;
}

public Context getContext() {
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/res/layout/wizard_step.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<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:transitionGroup="true">
android:layout_height="match_parent">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
Expand All @@ -21,10 +20,10 @@
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="64dp"
android:layout_marginTop="52dp"
android:ellipsize="end"
android:maxLines="2"
android:textAppearance="?attr/textAppearanceHeadlineMedium"
android:textAppearance="@style/TextAppearance.SketchwarePro.CollapsingToolbar.Expanded"
android:textColor="?attr/colorOnSurface"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/wizard_step_additional.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingEnd="24dp"
android:paddingStart="24dp">
android:paddingStart="24dp"
android:transitionGroup="true">

<TextView
android:layout_width="match_parent"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/wizard_step_basic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingEnd="24dp"
android:paddingStart="24dp">
android:paddingStart="24dp"
android:transitionGroup="true">

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_app_name"
Expand Down

0 comments on commit cf9f835

Please sign in to comment.