Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions layouteditor/src/main/assets/palette/layouts.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,15 @@
"android:layout_width": "match_parent",
"android:padding": "8dp"
}
},
{
"name": "DrawerLayout",
"className": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.DrawerLayoutDesign",
"iconName": "ic_palette_drawer_layout",
"defaultAttributes": {
"android:layout_width": "match_parent",
Comment thread
dara-abijo-adfa marked this conversation as resolved.
"android:layout_height": "match_parent",
"android:padding": "8dp"
}
}
]
1 change: 1 addition & 0 deletions layouteditor/src/main/assets/widgetclasses.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"FrameLayout": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.FrameLayoutDesign",
"TableLayout": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.TableLayoutDesign",
"TableRow": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.TableRowDesign",
"DrawerLayout":"org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.DrawerLayoutDesign",
"Space": "android.widget.Space",
"GridLayout": "org.appdevforall.codeonthego.layouteditor.editor.palette.legacy.GridLayoutDesign",
"TabHost": "org.appdevforall.codeonthego.layouteditor.editor.palette.legacy.TabHostDesign",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,57 @@
package org.appdevforall.codeonthego.layouteditor.editor.palette.containers;

import com.google.android.material.navigation.NavigationView;
import android.content.Context;
import android.graphics.Canvas;
import com.google.android.material.navigation.NavigationView;
import org.appdevforall.codeonthego.layouteditor.utils.Constants;
import org.appdevforall.codeonthego.layouteditor.utils.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class NavigationViewDesign extends NavigationView {

private boolean drawStrokeEnabled;
private boolean isBlueprint;

public NavigationViewDesign(Context context) {
super(context);
}

@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);

if (drawStrokeEnabled)
Utils.drawDashPathStroke(
this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR);
}

public void setStrokeEnabled(boolean enabled) {
drawStrokeEnabled = enabled;
invalidate();
}

@Override
public void draw(Canvas canvas) {
if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR);
else super.draw(canvas);
}

public void setBlueprint(boolean isBlueprint) {
this.isBlueprint = isBlueprint;
invalidate();
}

private boolean drawStrokeEnabled;
private boolean isBlueprint;

private final Logger logger = LoggerFactory.getLogger(NavigationViewDesign.class);

public NavigationViewDesign(Context context) {
super(context);
}

@Override
public void draw(Canvas canvas) {
if (isBlueprint)
Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR);
else
super.draw(canvas);
}

public void setBlueprint(boolean isBlueprint) {
this.isBlueprint = isBlueprint;
invalidate();
}

public void setStrokeEnabled(boolean enabled) {
drawStrokeEnabled = enabled;
invalidate();
}

@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);

if (drawStrokeEnabled)
Utils.drawDashPathStroke(
this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR);
}

@Override
protected void onAttachedToWindow() {
try {
super.onAttachedToWindow();
} catch (IllegalArgumentException e) {
logger.error("NavigationView should be placed in a DrawerLayout", e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.appdevforall.codeonthego.layouteditor.editor.palette.layouts

import android.content.Context
import android.graphics.Canvas
import androidx.drawerlayout.widget.DrawerLayout
import org.appdevforall.codeonthego.layouteditor.utils.Constants
import org.appdevforall.codeonthego.layouteditor.utils.Utils
import org.slf4j.Logger
import org.slf4j.LoggerFactory

class DrawerLayoutDesign(
context: Context,
) : DrawerLayout(context) {
private var drawStrokeEnabled = false
private var isBlueprint = false

private val logger: Logger = LoggerFactory.getLogger(DrawerLayoutDesign::class.java)

override fun dispatchDraw(canvas: Canvas) {
super.dispatchDraw(canvas)

if (drawStrokeEnabled) {
Utils.drawDashPathStroke(
this,
canvas,
if (isBlueprint) Constants.BLUEPRINT_DASH_COLOR else Constants.DESIGN_DASH_COLOR,
)
}
}

override fun draw(canvas: Canvas) {
if (isBlueprint) {
Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR)
} else {
super.draw(canvas)
}
Comment thread
dara-abijo-adfa marked this conversation as resolved.
}

fun setStrokeEnabled(enabled: Boolean) {
drawStrokeEnabled = enabled
invalidate()
}

fun setBlueprint(isBlueprint: Boolean) {
this.isBlueprint = isBlueprint
invalidate()
}

override fun onAttachedToWindow() {
try {
super.onAttachedToWindow()
} catch (e: Exception) {
logger.error("Error in previewing DrawerLayoutDesign", e)
}
}
}
Loading