123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- import 'package:flutter/material.dart';
- import 'package:ustest/Services/TestCase.dart';
- class TestCaseView extends StatelessWidget {
- const TestCaseView();
- @override
- Widget build(BuildContext context) {
- print("build TestCaseView");
- var tests = fetchTestCases();
- return Scaffold(
- body: Container(
- child: Column(
- children: [
- Padding(
- padding: EdgeInsets.all(8.0),
- child: Row(
- children: [
- IconButton(icon: Icon(Icons.play_circle_fill), onPressed: onRun)
- ],
- ),
- ),
- Padding(
- padding: EdgeInsets.all(8.0),
- child: Table(
- columnWidths: const <int, TableColumnWidth>{
- 0: FlexColumnWidth(50.0),
- 1: FixedColumnWidth(100.0),
- 2: FlexColumnWidth(80.0),
- 3: FlexColumnWidth(250.0),
- },
- border: TableBorder.all(
- color: Colors.green, width: 1.0, style: BorderStyle.solid),
- children: [
- TableRow(
- decoration: BoxDecoration(color: Colors.grey[200]),
- children: [
- Checkbox(value: false, onChanged: onSelectAllChanged),
- Text("URL",
- style: TextStyle(
- color: Colors.amber[900],
- backgroundColor: Colors.grey[200],
- fontSize: 16)),
- Text("METHOD"),
- Text("BODY")
- ],
- ),
- for (var i = 0; i < tests.length; i++)
- TableRow(
- children: [
- Checkbox(
- value: false,
- onChanged: (bool? value) {},
- ),
- Text(tests[i].url),
- Text(tests[i].method),
- Text(tests[i].body)
- ],
- )
- ],
- ),
- ),
- ],
- )),
- );
- }
- List<TestCase> fetchTestCases() {
- try {
- return <TestCase>[];
- var testCases = <TestCase>[];
- testCases.add(new TestCase(
- id: "1",
- url: "http://192.168.6.80:8303/IPatientService",
- method: "POST",
- body: '"{'
- '"jsonrpc": "2.0"'
- '"method": "FindPatients",'
- '"params": ['
- '{'
- '"Token": "1e8605f8991f423d9958196e21528b08",'
- '"KeyWord": "",'
- '"PageIndex": 1,'
- '"PageSize": 10'
- '}'
- '],'
- '"id": 1'
- '}"'));
- return testCases;
- } catch (ex) {
- print(ex);
- }
- return <TestCase>[];
- }
- void onAdd() {}
- void onRun() {}
- void onSelectAllChanged(bool? value) {}
- }
- class TestCaseList extends StatelessWidget {
- const TestCaseList({Key? key, required this.testCases}) : super(key: key);
- final List<TestCase> testCases;
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Scrollbar(
- child: ListView(
- restorationId: 'list_demo_list_view',
- padding: const EdgeInsets.symmetric(vertical: 0),
- children: [],
- ),
- ),
- );
- }
- }
- class Counter extends StatefulWidget {
- final testCase;
- Counter(this.testCase);
- @override
- _CounterState createState() => _CounterState();
- }
- class _CounterState extends State<Counter> {
- int qty = 0;
- @override
- Widget build(BuildContext context) {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Container(
- width: 30,
- child: TextButton(
- style: ButtonStyle(
- backgroundColor: MaterialStateProperty.resolveWith((states) {
-
- if (states.contains(MaterialState.pressed)) {
- return Colors.blue[200];
- }
-
- return null;
- }),
- ),
- onPressed: () async {
- var productItem = widget.testCase;
- if (qty > 0) {
- setState(() {
- qty--;
- productItem.qty = qty;
- });
- }
- },
- child: Text(
- '-',
- style: TextStyle(color: Colors.amber[900]),
- ),
- )),
- Text('$qty', style: TextStyle(color: Colors.black, fontSize: 12)),
- Container(
- width: 30,
- child: TextButton(
- onPressed: () async {
-
- if (qty < 100) {
- setState(() {
- qty++;
- });
- }
- },
- child: Text(
- '+',
- style: TextStyle(color: Colors.amber[900]),
- ),
- )),
- ],
- );
- }
- }
|