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 2d9563d commit d058a33
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@

import a.a.a.xB;

import mod.hey.studios.util.Helper;
import mod.remaker.activity.projectwizard.model.WizardStep;

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

public class BasicWizardStep extends WizardStep {
private WizardStepBasicBinding binding;

@Override
public String getTitle(Context context) {
return xB.b().a(context, R.string.project_wizard_basic_title);
Expand All @@ -25,10 +28,14 @@ public String getSubtitle(Context context) {

@Override
public View getContentView(LayoutInflater inflater, ViewGroup container) {
WizardStepBasicBinding binding = WizardStepBasicBinding.inflate(inflater, container, true);
binding.btnNext.setOnClickListener(v -> {
presentStep(new AdditionalWizardStep());
});
binding = WizardStepBasicBinding.inflate(inflater, container, true);

binding.btnNext.setOnClickListener(v -> presentStep(new AdditionalWizardStep()));

binding.tilAppName.setHint(Helper.getResString(R.string.myprojects_settings_hint_enter_application_name));
binding.tilPackageName.setHint(Helper.getResString(R.string.myprojects_settings_hint_enter_package_name));
binding.tilProjectName.setHint(Helper.getResString(R.string.myprojects_settings_hint_enter_project_name));

return binding.getRoot();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public void onCreate(Bundle savedInstanceState) {

@Override
public void onBackPressed() {
mWizardLayout.onBackPressed();
if (!mWizardLayout.onBackPressed()) {
super.onBackPressed();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface IWizardLayout {
void closeLastStep();
void setSteps(List<WizardStep> steps);
List<WizardStep> getSteps();
void onBackPressed();
boolean onBackPressed();

static IWizardLayout newLayout(Context context) {
return new WizardLayout(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class WizardLayout extends FrameLayout implements IWizardLayout {
private WizardStep oldStep;

private ProjectWizardActivity activity;

private List<WizardStep> steps;

public WizardLayout(Context context) {
Expand Down Expand Up @@ -152,9 +151,8 @@ public void setSteps(List<WizardStep> steps) {
this.steps = steps;

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

containerViewBack = new FrameLayout(activity);
Expand All @@ -176,13 +174,17 @@ public List<WizardStep> getSteps() {
}

@Override
public void onBackPressed() {
public boolean onBackPressed() {
WizardStep lastStep = getLastStep();

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

return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ 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.message.setText(getSubtitle(ctx));
}
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/res/layout/wizard_step.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
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"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
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"
Expand Down Expand Up @@ -43,13 +47,13 @@
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="12dp"
android:textAppearance="?attr/textAppearanceBodyMedium" />

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

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/project_wizard_strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources>
<string name="project_wizard_basic_title">New project</string>
<string name="project_wizard_basic_subtitle">Enter project name and package name to continue</string>
<string name="project_wizard_basic_subtitle">Enter project name and package name to continue.</string>
</resources>

0 comments on commit d058a33

Please sign in to comment.