Added base files for UI designer workspace

This commit is contained in:
Akash Yadav
2022-11-16 23:35:42 +05:30
parent 8f865f2024
commit 2022ed759b
8 changed files with 154 additions and 7 deletions
+1
View File
@@ -46,6 +46,7 @@ ext {
animated_vectors : 'androidx.vectordrawable:vectordrawable-animated:1.1.0',
multidex : 'androidx.multidex:multidex:2.0.1',
ktx : 'androidx.core:core-ktx:1.9.0',
fragment_ktx : 'androidx.fragment:fragment-ktx:1.5.4',
lib_desugaring : 'com.android.tools:desugar_jdk_libs:1.1.6',
splashscreen : 'androidx.core:core-splashscreen:1.0.0'
]
+2 -1
View File
@@ -487,9 +487,10 @@
<string name="widget_switch">Switch</string>
<string name="widget_textureview">TextureView</string>
<string name="widget_togglebutton">ToggleButton</string>
<string name="widget_webview">WebView</string>
<string name="widget_frame_layout">FrameLayout</string>
<string name="widget_grid_layout">GridLayout</string>
<string name="widget_linear_layout_horz">LinearLayout (H)</string>
<string name="widget_relative_layout">RelativeLayout</string>
<string name="widget_linear_layout_vert">LinearLayout (V)</string>
<string name="widget_relative_layout">RelativeLayout</string>
</resources>
+2
View File
@@ -38,6 +38,8 @@ android {
dependencies {
implementation androidx.appcompat
implementation androidx.ktx
implementation androidx.fragment_ktx
implementation google.material
implementation project(path: ':common')
@@ -0,0 +1,55 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.uidesigner.fragments
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import com.itsaky.androidide.fragments.BaseFragment
import com.itsaky.androidide.uidesigner.databinding.FragmentDesignerWorkspaceBinding
import com.itsaky.androidide.uidesigner.viewmodel.WorkspaceViewModel
/**
* The fragement that previews the inflated layout.
*
* @author Akash Yadav
*/
class DesignerWorkspaceFragment : BaseFragment() {
private var binding: FragmentDesignerWorkspaceBinding? = null
private val viewModel by viewModels<WorkspaceViewModel>()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
this.binding = FragmentDesignerWorkspaceBinding.inflate(inflater, container, false)
return this.binding!!.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel.observeCurrentView(viewLifecycleOwner) {
}
}
override fun onDestroyView() {
super.onDestroyView()
this.binding = null
}
}
@@ -0,0 +1,37 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.uidesigner.viewmodel
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModel
class WorkspaceViewModel : ViewModel() {
private val _currentView = MutableLiveData(0)
var currentView: Int
get() = _currentView.value!!
set(value) {
_currentView.value = value
}
fun observeCurrentView(owner: LifecycleOwner, observer: Observer<Int>) {
_currentView.observe(owner, observer)
}
}
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ This file is part of AndroidIDE.
~
~ AndroidIDE is free software: you can redistribute it and/or modify
@@ -45,6 +44,14 @@
</com.google.android.material.appbar.AppBarLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/workspace"
android:name="com.itsaky.androidide.uidesigner.fragments.DesignerWorkspaceFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:layout="@layout/fragment_designer_workspace" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
@@ -56,7 +63,7 @@
app:itemTextColor="@color/primaryTextColor">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/widgets_fragment_container"
android:id="@+id/widgets_fragment"
android:name="com.itsaky.androidide.uidesigner.fragments.WidgetsListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ This file is part of AndroidIDE.
~
~ AndroidIDE is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ AndroidIDE is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
-->
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingTop="32dp"
android:paddingBottom="32dp">
<ViewFlipper
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<include layout="@layout/layout_designer_error"/>
</ViewFlipper>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -15,6 +15,10 @@
~ along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
-->
<resources>
<string name="widget_webview">WebView</string>
</resources>
<com.google.android.material.textview.MaterialTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textAppearance="@style/TextAppearance.Material3.BodySmall"
tools:text="No views have been added." />