Skip to content

Commit

Permalink
feat: New screen for creating project
Browse files Browse the repository at this point in the history
  • Loading branch information
aikrq committed Dec 2, 2024
1 parent 83b0e94 commit a824fe6
Show file tree
Hide file tree
Showing 13 changed files with 723 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@
<activity android:name="mod.bobur.StringEditorActivity"
android:windowSoftInputMode="stateHidden|adjustPan"/>

<activity
android:name="mod.remaker.activity.projectwizard.ProjectWizardActivity"
android:configChanges="orientation|screenSize"
android:windowSoftInputMode="adjustResize" />

<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="true" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/mod/hey/studios/util/ProjectFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static int getDefaultColor(String color) {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
return switch (color) {
case COLOR_CONTROL_HIGHLIGHT -> ctx.getColor(isDark ? android.R.color.system_accent1_100 : android.R.color.system_accent1_900);
case COLOR_CONTROL_HIGHLIGHT -> ctx.getColor(isDark ? android.R.color.system_accent1_900 : android.R.color.system_accent1_100);
case COLOR_BACKGROUND ->
getLStaredColor(ctx, android.R.color.system_neutral2_600,
0xfffafafa, isDark ? 6.0f : 98.0f);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package mod.remaker.activity.projectwizard;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import a.a.a.xB;

import mod.remaker.activity.projectwizard.model.WizardStep;

import pro.sketchware.R;
import pro.sketchware.databinding.WizardStepAdditionalBinding;

public class AdditionalWizardStep extends WizardStep {
@Override
public String getTitle(Context context) {
return "Configure your project";
}

@Override
public String getSubtitle(Context context) {
return "Choose what you need.";
}

@Override
public View getContentView(LayoutInflater inflater, ViewGroup container) {
WizardStepAdditionalBinding binding = WizardStepAdditionalBinding.inflate(inflater, container, true);
return binding.getRoot();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package mod.remaker.activity.projectwizard;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import a.a.a.xB;

import mod.remaker.activity.projectwizard.model.WizardStep;

import pro.sketchware.R;
import pro.sketchware.databinding.WizardStepBasicBinding;

public class BasicWizardStep extends WizardStep {
@Override
public String getTitle(Context context) {
return xB.b().a(context, R.string.project_wizard_basic_title);
}

@Override
public String getSubtitle(Context context) {
return xB.b().a(context, R.string.project_wizard_basic_subtitle);
}

@Override
public View getContentView(LayoutInflater inflater, ViewGroup container) {
WizardStepBasicBinding binding = WizardStepBasicBinding.inflate(inflater, container, true);
binding.btnNext.setOnClickListener(v -> {
presentStep(new AdditionalWizardStep());
});
return binding.getRoot();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package mod.remaker.activity.projectwizard;

import static androidx.core.view.WindowCompat.setDecorFitsSystemWindows;

import android.os.Bundle;
import android.view.ViewGroup;

import com.besome.sketch.lib.base.BaseAppCompatActivity;

import mod.remaker.activity.projectwizard.model.IWizardLayout;
import mod.remaker.activity.projectwizard.model.WizardStep;

import java.util.ArrayList;

public class ProjectWizardActivity extends BaseAppCompatActivity {
private static final ArrayList<WizardStep> steps = new ArrayList<>();

private IWizardLayout mWizardLayout;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

mWizardLayout = IWizardLayout.newLayout(this);
mWizardLayout.setSteps(steps);

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

ViewGroup parent = (ViewGroup) mWizardLayout.getView().getParent();
if (parent != null) {
parent.removeView(mWizardLayout.getView());
}

if (mWizardLayout.getSteps().isEmpty()) {
mWizardLayout.addStep(new BasicWizardStep());
}
}

@Override
public void onBackPressed() {
mWizardLayout.onBackPressed();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package mod.remaker.activity.projectwizard.model;

import android.content.Context;
import android.view.ViewGroup;

import java.util.List;

public interface IWizardLayout {
int FORCE_NOT_ATTACH_VIEW = -2;

boolean presentStep(WizardParams params);
boolean addStep(WizardStep step, int position);
void removeStep(WizardStep step, boolean immediate);
void closeLastStep();
void setSteps(List<WizardStep> steps);
List<WizardStep> getSteps();
void onBackPressed();

static IWizardLayout newLayout(Context context) {
return new WizardLayout(context);
}

default ViewGroup getView() {
if (this instanceof ViewGroup) {
return (ViewGroup) this;
}
throw new IllegalArgumentException("You should override `getView()` if you aren't inheriting from it.");
}

default boolean presentStep(WizardStep step) {
return presentStep(new WizardParams(step));
}

default boolean addStep(WizardStep step) {
return addStep(step, -1);
}

default void removeStep(int position) {
if (position < 0 || position >= getSteps().size()) {
return;
}
removeStep(getSteps().get(position));
}

default void removeStep(WizardStep step) {
removeStep(step, false);
}

default void bringToFront(int i) {
WizardStep step = getSteps().get(i);
removeStep(step);
addStep(step);
// rebuildSteps(REBUILD_FLAG_REBUILD_ONLY_LAST);
}

class WizardParams {
public WizardStep step;
public boolean removeLast;

public WizardParams(WizardStep step) {
this.step = step;
}

public WizardParams setRemoveLast(boolean removeLast) {
this.removeLast = removeLast;
return this;
}
}
}
Loading

0 comments on commit a824fe6

Please sign in to comment.