All Projects → maoruibin → Viewcontroller

maoruibin / Viewcontroller

Licence: apache-2.0
📌 A view controller manages a set of views that make up a portion of your app’s user interface,it aims to make ui develop change more clear and flexible.(ViewControler 是一种界面开发组件化实现方式,利用它可以将一些复杂的 UI 界面开发组件化.)

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Viewcontroller

React Modal Box
React Modal Box, is a simple dependency free and customizable React Component to display Modals on your application. Its simple event system allows you to place the modal in the root component of your application, and calling it with the simple mixins, allows you to be flexible. It also includes event handling mixins, so you can detect when the modal is being called or being hidden.
Stars: ✭ 126 (+7.69%)
Mutual labels:  flexible, components
Redux Autoform
Create Redux-Forms dynamically out of metadata
Stars: ✭ 113 (-3.42%)
Mutual labels:  components
Data Components
♻️ Tiny component structure for web applications
Stars: ✭ 100 (-14.53%)
Mutual labels:  components
Atlas.js
A component-based Node.js library to reduce boilerplate and provide sane project structure 🍻
Stars: ✭ 108 (-7.69%)
Mutual labels:  components
Pd Select
vue components ,like ios 3D picker style,vue 3d 选择器组件,3D滚轮
Stars: ✭ 101 (-13.68%)
Mutual labels:  components
React Multi Select
A Multi Select component built with and for React
Stars: ✭ 111 (-5.13%)
Mutual labels:  components
Devextreme React
React UI and data visualization components
Stars: ✭ 100 (-14.53%)
Mutual labels:  components
Reactstrap
Simple React Bootstrap 5 components
Stars: ✭ 10,207 (+8623.93%)
Mutual labels:  components
Candela
Visualization components for the web
Stars: ✭ 112 (-4.27%)
Mutual labels:  components
Dddplus
🔥 A lightweight flexible development framework for complex business architecture with full ecosystem!轻量级业务中台开发框架,中台架构的顶层设计和完整解决方案!
Stars: ✭ 107 (-8.55%)
Mutual labels:  flexible
Freeesvclcomponents
Free ErrorSoft components for delphi (VCL) & EsVclCore lib
Stars: ✭ 106 (-9.4%)
Mutual labels:  components
Rdgliderviewcontroller Swift
Control for a floating view gliding over a ViewController Edit
Stars: ✭ 102 (-12.82%)
Mutual labels:  viewcontroller
Shari
Shari is the alternative to the library of UIPickerView(drum roll) in Swift. You can select a item using UITableView.
Stars: ✭ 111 (-5.13%)
Mutual labels:  viewcontroller
Re Jok
A React UI Component library built with styled-components
Stars: ✭ 102 (-12.82%)
Mutual labels:  components
Composite
A component-based OS
Stars: ✭ 113 (-3.42%)
Mutual labels:  components
Uniforms
A React library for building forms from any schema.
Stars: ✭ 1,368 (+1069.23%)
Mutual labels:  components
Server Components Mdx Demo
React server components + MDX
Stars: ✭ 102 (-12.82%)
Mutual labels:  components
React Collection Helpers
A suite of composable utility components to manipulate collections.
Stars: ✭ 109 (-6.84%)
Mutual labels:  components
Vcomponents
VComponents is a SwiftUI framework that contains 40+ customizable UI components
Stars: ✭ 117 (+0%)
Mutual labels:  components
React Workshop
⚒ 🚧 This is a workshop for learning how to build React Applications
Stars: ✭ 114 (-2.56%)
Mutual labels:  components

ViewController

A view controller manages a set of views that make up a portion of your app’s user interface, it aims to make ui develop change more clear and flexible.

English | 中文 | Android 复杂界面开发实践之 ViewController: 介绍

demo

Advantage

  • Make UI development components,resolve problem of code bloated.
  • flexible, one component can used in more place.
  • easy use, easy develop.

Usage

As a good practice, I recommend you run or watch demo code directly.

import dependency

you can import dependency or copy source file to your project directly, so far, only one file in this lib.

Add the JitPack repository to your build file

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

Add the dependency

dependencies {
	 compile 'com.github.maoruibin:ViewController:0.9.1'
}

develop component

just like this demo image, we should develop four component.

now I want to develop comment component as a demo, i will introduce the point by code annotation.

// 1、every component mast extends ViewController
public class HouseCommentViewController extends ViewController<List<String>> 

// 2、indicate layout id for this component  
@Override
protected int resLayoutId() {
    return R.layout.detail_comment_layout;
}

// init this component's view element 
@Override
protected void onCreatedView(View view) {
    mLlContainer = view.findViewById(R.id.ll_container);
    ...
}

// bind data to this view component 
@Override
protected void onBindView(List<String> comments) {
    for (String comment:comments) {
        TextView view = new TextView(getContext());
        view.setBackgroundResource(R.color.bk_item);
        view.setText(comment);
        int padding = Utils.dp2px(16);
        view.setPadding(padding,padding,padding,padding);
        mLlContainer.addView(view);
    }
}

Now, we have finished a simple view component, and you can watch left components implement by demo code.

Assemble Component in Activity

We have finished four components for house detail UI.

HousePhotoViewController    //House picture component 
HouseParamViewController    //House param info component
HouseDescViewController     //House description component
HouseCommentViewController  //House comment component

the left job is assemble. the core of assemble is

every view controller support a way to attach owner's view to root layout,so activity should have a root layout use to fill all views.

The java code is like this

// 1、define ViewController instance
private ViewController<List<String>> mHousePhotoViewController;
private ViewController<HouseDetail.Param> mHouseParamViewController;
private ViewController<List<String>> mHouseCommentViewController;
private ViewController<String> mHouseDescViewController;

// 2、init instance 
mHousePhotoViewController = new HousePhotoViewController(this);
mHouseParamViewController = new HouseParamViewController(this);
mHouseDescViewController = new HouseDescViewController(this);
mHouseCommentViewController = new HouseCommentViewController(this);

// 3、attach view controller to activity root, usually the best choose for root is a vertical LinearLayout. 
mHousePhotoViewController.attachRoot(mLlContainer);
mHouseParamViewControler.attachRoot(mLlContainer);
mHouseDescViewControler.attachRoot(mLlContainer);
mHouseCommentViewControler.attachRoot(mLlContainer);

// 4 、mock get data 
getData();

// 5、fill data to UI 

fillData();

// 6、fill data to different view controller
private void fillData(HouseDetail detail) {
    mHousePhotoViewController.fillData(detail.photos);
    mHouseParamViewController.fillData(detail.param);
    mHouseDescViewController.fillData(detail.desc);
    mHouseCommentViewController.fillData(detail.comments);
}

and now, a complex ui had split four components, by this way, every components only deal with owner logic.

And if other activity or fragment have a same component need implement, you can reuse code directly, nice!

TODO

  • [ ] Manage lifecycle
  • [ ] Support a AndroidStudio Templete for generate ViewController frame

Author

http://gudong.name

https://github.com/maoruibin

License

Copyright 2016 咕咚

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].