lsp_designer 0.1.36

lsp_designer #

License Pub Codacy Badge

A practical component library from Logistics Service Management Product Group feels silky and smooth when used. 🚀

github

lsp_designer.gif

dependencies:
 lsp_designer: ^0.1.36

Usage example #

MultipleSelect #

MultipleSelect.showMultipleSelector(
                context,
                dataList: List.generate(15, (index) => MultipleSelectItem.build(value: index, display: '第$index项显示内容', content: '第$index项下拉内容')),
              ).then((selectedList) {
                if (selectedList != null) selectedList.forEach((item) => print(item.display));
              });

MultipleDropDown #

List<MultipleSelectItem> elements = List.generate(15, (index) => MultipleSelectItem.build(value: index, display: '$index display', content: '$index content'));

List _selectedValues = elements.where((element) => element.value % 2 == 0).map((item) => item.value).toList();
MultipleDropDown(
          placeholder: '请选择',
          disabled: false,
          values: _selectedValues,
          elements: elements,
          onConfirm: (selectedValues) {
            this.setState(() => this._selectedValues = selectedValues);
          },
        )

SingleElection #

SingleElection #

SingleElection.build( {@required this.list, @required this.value, @required this.onPressed, this.color});

SingleElectionItem #

SingleElectionItem(this.label, this.value);

SingleElection.build(
    value: this._billType,
    color: Colors.orange,
    list: List.generate(
                2,
                (index) =>
                    SingleElectionItem('开单类型' + index.toString(), index.toString())),
    onPressed: (item) =>
        this.setState(() => this._billType = item.value),
)

Selector #

Selector( {@required this.value, @required this.label, @required this.hint, @required this.store, @required this.onChange});

Selector(
    value: this._payMode,
    label: Text(
      '付款方式:',
      style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
    ),
    hint: Container(
      padding: EdgeInsets.only(left: 10.0),
      child: Text('请选择付款方式'),
    ),
    store: List.generate(
                   5,
                   (index) => DropdownMenuItem(
                         value: '001' + index.toString(),
                         child: Container(
                           padding: EdgeInsets.only(left: 10),
                           child: Text('付款方式' + index.toString()),
                         ),
                       )),
    onChange: (item) => this.setState(() => this._payMode = item),
)

CircularSheet #

CircularSheet( {this.head, @required this.child, this.borderRadius, this.height});

CircularSheet(
  head: Text(
    'TITLE',
    style: TextStyle(
      fontSize: 15,
      color: Colors.black45,
    ),
  ),
  child: Container(color: Colors.blue),
)

VagueSelector #

  • D 文本框显示的内容
  • V 存储的内容
  • C 下拉列表每行的显示的内容

VagueSelector<D, V, C>

VagueSelector.build( {@required this.label, @required this.list, @required this.onPressed});

SelectorItem<D, V, C>

SelectorItem( {@required this.display, @required this.value, @required this.content});

VagueSelector.build(
    value: this._associateBill,
    label: Text(
      '关联单据:',
      style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
    ),
    list: List<SelectorItem>.generate(15, (index) {
      return SelectorItem(
          display: 'AB-190517' + index.toString(),
          value: '190517' + index.toString(),
          content: '单据:AB-190517' + index.toString());
    }),
    onPressed: (value) {
      this.setState(() => this._associateBill = value);
    },
)

Contribute #

We would ❤️ to see your contribution!

License #

Distributed under the MIT license. See LICENSE for more information.

About #

Created by Shusheng.

0.1.0 #

2019/05/17

0.1.1 #

2019/05/18

0.1.2 #

2019/05/18

0.1.3 #

2019/05/20

  • Remove the generics of button groups.

0.1.4 #

2019/05/20

0.1.5 #

2019/05/21

0.1.6 #

2019/05/25

  • VagueSelector can disabled
  • VagueSelector repair set default value

0.1.7 #

2019/05/25

  • Selector can disabled

0.1.8 #

2019/05/25

0.1.9 #

2019/05/25

0.1.10 #

2019/05/25

  • SingleElection can disabled

0.1.11 #

2019/05/28

0.1.12 #

2019/05/28

0.1.13 #

2019/05/30

0.1.14 #

2019/05/30

0.1.15 #

  • DialogHolder 2019/06/04

0.1.16 #

  • NumberField 2019/06/04

0.1.17 #

  • Snack 2019/06/04

0.1.18 #

  • Snack 2019/06/04

0.1.19 #

  • Repair VagueSelector 2019/06/07

0.1.20 #

2019/06/07

0.1.21 #

2019/06/14

0.1.22 #

  • update NumberField
  • update path of component

0.1.23 #

2019/07/05

  • add multiple_select

0.1.24 #

2019/07/09

  • modify multi_drop_down style

0.1.25 #

2019/07/09

  • make multi_drop_down support default values

0.1.26 #

2019/07/09

  • make multi_drop_down support disable

0.1.27 #

2019/07/09

  • modify multi_drop_down style

0.1.28 #

2019/07/09

  • modify multi_drop_down widget make the values was required

0.1.29 #

2019/07/09

  • avoid null point exception

0.1.30 #

2019/07/09

  • rename the multi_drop_down arg

0.1.31 #

2019/07/09

  • deserialization

0.1.32 #

2019/07/09

  • deserialization

0.1.33 #

2019/07/11

  • update

0.1.34 #

2019/07/11

  • update

0.1.35 #

2019/07/11

  • update style

0.1.36 #

2019/07/11

  • update style

example/README.md

lsp_designer_example #

Usage example #

import 'package:flutter/material.dart';
import 'package:lsp_designer_example/BillModel.dart';
import 'package:lsp_designer/form/SingleElection.dart';
import 'package:lsp_designer/form/Selector.dart';
import 'package:lsp_designer/form/VagueSelector.dart';
import 'package:lsp_designer/form/NumberField.dart';

class AddBill extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => new AddBillState();
}

class AddBillState extends State<AddBill> {
  BillModel bill = BillModel.build();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomPadding: true,
      appBar: AppBar(
        title: Text('LSP_DESIGNER'),
      ),
      body: ListView(
        children: <Widget>[
          Selector(
            value: this.bill.supplier,
            label: Text(
              '供  应  商:',
              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
            ),
            hint: Container(
              padding: EdgeInsets.only(left: 10.0),
              child: Text('请选择供应商'),
            ),
            store: this._supplierStore(),
            onChange: (item) => this.setState(() => this.bill.supplier = item),
          ),
          VagueSelector.build(
            value: this.bill.associateBill,
            label: Text(
              '关联单据:',
              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
            ),
            list: List<SelectorItem>.generate(15, (index) {
              return SelectorItem(display: 'AB-190517' + index.toString(), value: '190517' + index.toString(), content: '单据:AB-190517' + index.toString());
            }),
            onPressed: (value) {
              if (value != null) this.setState(() => this.bill.associateBill = value);
            },
            placeholder: '请选择关联单据',
          ),
          Container(
            margin: EdgeInsets.symmetric(vertical: 18, horizontal: 8),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '采购方式:',
                  style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
                ),
                Container(
                  padding: EdgeInsets.only(top: 10),
                  child: SingleElection.build(
                    value: this.bill.purchaseMode,
                    color: Colors.deepOrange,
                    list: this._purchaseModeList,
                    onPressed: (item) => this.setState(() => this.bill.purchaseMode = item.value),
                  ),
                ),
              ],
            ),
          ),
          Selector(
            value: this.bill.acceptor,
            label: Text(
              '验  收  人:',
              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
            ),
            hint: Container(
              padding: EdgeInsets.only(left: 10.0),
              child: Text('请选择验收人'),
            ),
            store: this._acceptorStore(),
            onChange: (item) => this.setState(() => this.bill.acceptor = item),
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              Padding(
                padding: EdgeInsets.only(left: 8),
                child: Text(
                  '数        量:',
                  style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
                ),
              ),
              Padding(
                padding: EdgeInsets.symmetric(vertical: 10, horizontal: 6),
                child: NumberField.build(
                  initValue: 0,
                  miniValue: 0,
                  maxValue: 100,
                  onChange: (value) {
                    print(value);
                  },
                ),
              ),
            ],
          ),
        ],
      ),
      bottomNavigationBar: BottomAppBar(
        shape: CircularNotchedRectangle(),
        notchMargin: 30.0,
        color: Theme.of(context).primaryColor,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            IconButton(icon: Icon(Icons.hot_tub, color: Colors.white), onPressed: () {}),
            IconButton(icon: Icon(Icons.add_a_photo, color: Colors.white), onPressed: () {})
          ],
        ),
      ),
      floatingActionButton: SaveButton(
          successCallback: () => this.setState(() {
                this.bill = BillModel.build();
              })),
      floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
    );
  }

  List<SingleElectionItem> _purchaseModeList = List.generate(5, (index) => SingleElectionItem('采购方式' + index.toString(), index.toString()));

  _supplierStore() {
    return List.generate(
        5,
        (index) => DropdownMenuItem(
              value: '001' + index.toString(),
              child: Container(
                padding: EdgeInsets.only(left: 10),
                child: Text('测试供应商' + index.toString()),
              ),
            ));
  }

  _acceptorStore() {
    return List.generate(
        10,
        (index) => DropdownMenuItem(
              value: '001' + index.toString(),
              child: Container(
                padding: EdgeInsets.only(left: 10),
                child: Text('验收人' + index.toString()),
              ),
            ));
  }
}

class SaveButton extends StatelessWidget {
  SaveButton({this.successCallback});

  final Function successCallback;

  @override
  Widget build(BuildContext context) {
    return FloatingActionButton.extended(
      onPressed: () {
        if (this.successCallback != null) this.successCallback();
        this._showSnackBar(context, '保存成功', true);
      },
      foregroundColor: Colors.white,
      backgroundColor: Colors.cyan,
      icon: Icon(
        Icons.send,
      ),
      label: Text(' 提  交'),
    );
  }

  _showSnackBar(context, content, successful) {
    final snackBar = SnackBar(
      content: Row(
        children: <Widget>[
          Padding(
            padding: EdgeInsets.only(right: 10),
            child: Icon(Icons.notifications_active, color: Colors.black),
          ),
          Text(
            content,
            style: TextStyle(color: Colors.black54),
          )
        ],
      ),
      backgroundColor: successful ? Colors.green : Colors.yellowAccent,
      action: SnackBarAction(label: '关 闭', textColor: Colors.black54, onPressed: () {}),
      duration: Duration(seconds: 3),
    );
    Scaffold.of(context).showSnackBar(snackBar);
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  lsp_designer: ^0.1.36

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:lsp_designer/card/CircularSheet.dart';
import 'package:lsp_designer/dialog/DialogHolder.dart';
import 'package:lsp_designer/dialog/Snack.dart';
import 'package:lsp_designer/form/multiple_select.dart';
import 'package:lsp_designer/form/multi_drop_down.dart';
import 'package:lsp_designer/form/NumberField.dart';
import 'package:lsp_designer/form/Selector.dart';
import 'package:lsp_designer/form/SingleElection.dart';
import 'package:lsp_designer/form/VagueSelector.dart';
import 'package:lsp_designer/list/DynamicListView.dart';
import 'package:lsp_designer/process/LoadingProcess.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
26
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/dialog/DialogHolder.dart.

Run flutter format to format lib/dialog/DialogHolder.dart.

Format lib/form/NumberField.dart.

Run flutter format to format lib/form/NumberField.dart.

Format lib/form/Selector.dart.

Run flutter format to format lib/form/Selector.dart.

Fix additional 5 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/form/SingleElection.dart (Run flutter format to format lib/form/SingleElection.dart.)
  • lib/form/VagueSelector.dart (Run flutter format to format lib/form/VagueSelector.dart.)
  • lib/form/multi_drop_down.dart (Run flutter format to format lib/form/multi_drop_down.dart.)
  • lib/form/multiple_select.dart (Run flutter format to format lib/form/multiple_select.dart.)
  • lib/process/LoadingProcess.dart (Run flutter format to format lib/process/LoadingProcess.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test

Admin