forked from Sketchware-Pro/Sketchware-Pro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: New screen for creating project
- Loading branch information
Showing
13 changed files
with
721 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/src/main/java/mod/remaker/activity/projectwizard/AdditionalWizardStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/mod/remaker/activity/projectwizard/BasicWizardStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
app/src/main/java/mod/remaker/activity/projectwizard/ProjectWizardActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, 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(); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
app/src/main/java/mod/remaker/activity/projectwizard/model/IWizardLayout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.