lsp_designer 0.1.38

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.38

Usage example #

import 'package:flutter/material.dart';
import 'package:lsp_designer/form/SingleElection.dart';
import 'package:lsp_designer/form/Selector.dart';
import 'package:lsp_designer/form/Input.dart';
import 'package:lsp_designer/form/multi_election.dart';
import 'package:lsp_designer/form/constant/style_constant.dart';
import 'package:lsp_designer/form/VagueSelector.dart';
import 'package:lsp_designer/form/NumberField.dart';

var associateBillStore = List<SelectorItem>.generate(
    15, (index) => SelectorItem(display: 'AB-190517' + index.toString(), value: '190517' + index.toString(), content: '单据:AB-190517' + index.toString()));
var acceptorStore = List.generate(
    10, (index) => DropdownMenuItem(value: '001' + index.toString(), child: Container(padding: EdgeInsets.only(left: 10), child: Text('验收人' + index.toString()))));
var supplierStore = List.generate(
    5, (index) => DropdownMenuItem(value: '001' + index.toString(), child: Container(padding: EdgeInsets.only(left: 10), child: Text('测试供应商' + index.toString()))));
var purchaseModeStore = List.generate(5, (index) => SingleElectionItem('采购方式' + index.toString(), index.toString()));

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: AddBill(),
    );
  }
}

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

class AddBillState extends State<AddBill> {
  BillModel bill = BillModel();
  List _selectedValues = [];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomPadding: true,
      appBar: AppBar(
        backgroundColor: Colors.grey,
        title: Text('LSP_DESIGNER'),
      ),
      body: ListView(
        children: <Widget>[
          Input(
            leading: Icon(Icons.straighten, color: Colors.black45),
            label: '桌子长度',
            hint: '请输入长度',
            trailing: Text('cm', style: CustomStyle.unitStyle),
          ),
          Divider(height: 1),
          CheckboxListTile(
            secondary: const Icon(Icons.bubble_chart, color: Colors.black45),
            title: Text('是否异常', style: CustomStyle.labelStyle),
            value: false,
            onChanged: (value) {},
          ),
          Divider(height: 1),
          MultiElection.build(
            label: '异常类型',
            leading: Icon(Icons.multiline_chart, color: Colors.black45),
            value: _selectedValues,
            selectedColor: Colors.red,
            list: List.generate(5, (index) => MultiElectionItem('异常类型' + index.toString(), index.toString())),
            onPressed: (item) {
              var value = item.value;
              if (_selectedValues.contains(value)) {
                _selectedValues.remove(value);
              } else {
                _selectedValues.add(value);
              }
              this.setState(() => _selectedValues = _selectedValues);
            },
          ),
          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: supplierStore,
            onChange: (item) => this.setState(() => this.bill.supplier = item),
          ),
          VagueSelector.build(
            placeholder: '请选择关联单据',
            value: this.bill.associateBill,
            label: Text('关联单据:', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0)),
            list: associateBillStore,
            onPressed: (value) => this.setState(() => this.bill.associateBill = value),
          ),
          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: purchaseModeStore,
                    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: 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),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}

class BillModel {
  String uuid;
  String supplier;
  String associateBill;
  String purchaseMode;
  String acceptor;
  int quantity;
}

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

0.1.37 #

2019/07/23

  • update style

0.1.38 #

2019/12/26

  • Add several components

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.38

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/constant/formatter_constant.dart';
import 'package:lsp_designer/form/constant/style_constant.dart';
import 'package:lsp_designer/form/headline.dart';
import 'package:lsp_designer/form/input.dart';
import 'package:lsp_designer/form/multiple_select.dart';
import 'package:lsp_designer/form/multi_drop_down.dart';
import 'package:lsp_designer/form/multi_election.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]
0
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]
50
Learn more about scoring.

We analyzed this package on Feb 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health suggestions

Fix lib/form/VagueSelector.dart. (-0.50 points)

Analysis of lib/form/VagueSelector.dart reported 1 hint:

line 7 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: VagueSelector.value

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.

Fix additional 8 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/form/Selector.dart (Run flutter format to format lib/form/Selector.dart.)
  • lib/form/SingleElection.dart (Run flutter format to format lib/form/SingleElection.dart.)
  • lib/form/constant/formatter_constant.dart (Run flutter format to format lib/form/constant/formatter_constant.dart.)
  • lib/form/headline.dart (Run flutter format to format lib/form/headline.dart.)
  • lib/form/multi_drop_down.dart (Run flutter format to format lib/form/multi_drop_down.dart.)
  • lib/form/multi_election.dart (Run flutter format to format lib/form/multi_election.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 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test