Skip to content

Commit

Permalink
Freeze columns.
Browse files Browse the repository at this point in the history
  • Loading branch information
edufolly committed Mar 2, 2021
1 parent 21c62fe commit 81e2bf7
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 99 deletions.
54 changes: 50 additions & 4 deletions example/lib/example_table.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import 'package:flutter/material.dart';
import 'package:folly_fields/validators/cnpj_validator.dart';
import 'package:folly_fields/validators/cpf_validator.dart';
import 'package:folly_fields/validators/mac_address_validator.dart';
import 'package:folly_fields/validators/phone_validator.dart';
import 'package:folly_fields/widgets/folly_table.dart';
import 'package:folly_fields_example/advanced/example_builder.dart';
import 'package:folly_fields_example/advanced/example_consumer.dart';
import 'package:folly_fields_example/advanced/example_edit.dart';
import 'package:folly_fields_example/example_model.dart';

///
Expand All @@ -26,6 +30,7 @@ class _ExampleTableState extends State<ExampleTable> {
final CpfValidator cpfValidator = CpfValidator();
final CnpjValidator cnpjValidator = CnpjValidator();
final PhoneValidator phoneValidator = PhoneValidator();
final MacAddressValidator macAddressValidator = MacAddressValidator();

final double rowHeight = 26.0;

Expand All @@ -42,40 +47,81 @@ class _ExampleTableState extends State<ExampleTable> {
padding: const EdgeInsets.all(16.0),
child: FollyTable(
rowsCount: list.length,
headerHeight: rowHeight * 2.1,
headerHeight: rowHeight,
rowHeight: rowHeight,
columnsSize: <double>[160.0, 250.0, 150.0, 200.0, 100.0, 150.0],
freezeColumns: 2,
columnsSize: <double>[
160.0,
230.0,
150.0,
200.0,
100.0,
150.0,
150.0,
],
headerColumns: <FollyCell>[
FollyCell.textHeaderCenter('Text'),
FollyCell.textHeaderCenter('E-mail'),
FollyCell.textHeaderCenter('CPF'),
FollyCell.textHeaderCenter('CNPJ'),
FollyCell.textHeaderCenter('Decimal'),
FollyCell.textHeaderCenter('Telefone'),
FollyCell.textHeaderCenter('MAC Address'),
],
cellBuilder: (int row, int col) {
ExampleModel model = list[row];
switch (col) {
case 0:
return FollyCell.text(model.text);

case 1:
return FollyCell.text(model.email);

case 2:
return FollyCell.text(cpfValidator.format(model.cpf));
return FollyCell.text(
cpfValidator.format(model.cpf),
align: Alignment.center,
textAlign: TextAlign.center,
);

case 3:
return FollyCell.text(cnpjValidator.format(model.cnpj));
return FollyCell.text(
cnpjValidator.format(model.cnpj),
align: Alignment.center,
textAlign: TextAlign.center,
);

case 4:
return FollyCell.number(model.decimal.value);

case 5:
return FollyCell.text(
phoneValidator.format(model.phone),
align: Alignment.center,
textAlign: TextAlign.center,
);

case 6:
return FollyCell.text(
macAddressValidator.format(model.macAddress),
align: Alignment.center,
textAlign: TextAlign.center,
);

default:
return FollyCell.text('ERRO: $row - $col');
}
},
onRowTap: (int row) => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => ExampleEdit(
list[row],
ExampleBuilder(null),
ExampleConsumer(),
false,
),
),
),
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.24+24"
version: "0.0.25+25"
font_awesome_flutter:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A new Flutter project.

publish_to: 'none'

version: 0.0.24+24
version: 0.0.25+25

environment:
sdk: ">=2.7.0 <3.0.0"
Expand All @@ -17,7 +17,7 @@ dependencies:
path: ../

# https://pub.dev/packages/http
http: 0.12.2
http: ^0.12.2
# https://pub.dev/packages/url_launcher
url_launcher: ^5.7.10
# https://pub.dev/packages/google_fonts
Expand Down
Loading

0 comments on commit 81e2bf7

Please sign in to comment.