refactor
This commit is contained in:
parent
b6a46673cf
commit
5f5487803b
4 changed files with 35 additions and 35 deletions
|
@ -1,15 +1,13 @@
|
||||||
import 'package:cdb_ui/api.dart';
|
import 'package:cdb_ui/api.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'supply.dart';
|
|
||||||
|
|
||||||
class ConsumePage extends StatefulWidget {
|
class ConsumePage extends StatefulWidget {
|
||||||
final String item;
|
final String item;
|
||||||
final String variant;
|
final String variant;
|
||||||
final String transaction;
|
final String transaction;
|
||||||
Function refresh;
|
final Function refresh;
|
||||||
|
|
||||||
ConsumePage(this.transaction, this.item, this.variant, this.refresh,
|
const ConsumePage(this.transaction, this.item, this.variant, this.refresh,
|
||||||
{super.key});
|
{super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -26,7 +26,7 @@ class _ItemViewState extends State<ItemView> {
|
||||||
),
|
),
|
||||||
body: Column(children: [
|
body: Column(children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 28),
|
padding: const EdgeInsets.symmetric(horizontal: 28),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
|
@ -39,7 +39,7 @@ class _ItemViewState extends State<ItemView> {
|
||||||
fallbackHeight: 100,
|
fallbackHeight: 100,
|
||||||
),
|
),
|
||||||
), // todo
|
), // todo
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
width: 16.0,
|
width: 16.0,
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
|
@ -60,13 +60,13 @@ class _ItemViewState extends State<ItemView> {
|
||||||
return Column(children: [
|
return Column(children: [
|
||||||
Text(
|
Text(
|
||||||
entry.value.name,
|
entry.value.name,
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: API().getStat(widget.item.id, entry.key),
|
future: API().getStat(widget.item.id, entry.key),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
return CircularProgressIndicator();
|
return const CircularProgressIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
var stat = snapshot.data!;
|
var stat = snapshot.data!;
|
||||||
|
@ -82,7 +82,7 @@ class _ItemViewState extends State<ItemView> {
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
}).toList()),
|
}).toList()),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
height: 12,
|
height: 12,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@ -115,9 +115,9 @@ class _ItemViewState extends State<ItemView> {
|
||||||
|
|
||||||
class TransactionCard extends StatelessWidget {
|
class TransactionCard extends StatelessWidget {
|
||||||
final Transaction t;
|
final Transaction t;
|
||||||
Function refresh;
|
final Function refresh;
|
||||||
|
|
||||||
TransactionCard(this.t, this.refresh, {super.key});
|
const TransactionCard(this.t, this.refresh, {super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -131,13 +131,13 @@ class TransactionCard extends StatelessWidget {
|
||||||
},
|
},
|
||||||
child: Card(
|
child: Card(
|
||||||
color: t.expired ? Colors.red[100] : Colors.black,
|
color: t.expired ? Colors.red[100] : Colors.black,
|
||||||
margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
elevation: 4,
|
elevation: 4,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
@ -148,9 +148,9 @@ class TransactionCard extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
t.item,
|
t.item,
|
||||||
style: TextStyle(fontSize: 16),
|
style: const TextStyle(fontSize: 16),
|
||||||
),
|
),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
width: 4,
|
width: 4,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
|
@ -165,25 +165,26 @@ class TransactionCard extends StatelessWidget {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.money, size: 18, color: Colors.green),
|
const Icon(Icons.money, size: 18, color: Colors.green),
|
||||||
SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
Text(
|
Text(
|
||||||
"${t.price.value.toStringAsFixed(2)} ${t.price.currency}",
|
"${t.price.value.toStringAsFixed(2)} ${t.price.currency}",
|
||||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
style: const TextStyle(
|
||||||
|
fontSize: 16, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (t.origin != null) ...[
|
if (t.origin != null) ...[
|
||||||
SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.store, size: 18, color: Colors.blue),
|
const Icon(Icons.store, size: 18, color: Colors.blue),
|
||||||
SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
Text(
|
Text(
|
||||||
t.origin!,
|
t.origin!,
|
||||||
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
|
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import 'package:cdb_ui/api.dart';
|
import 'package:cdb_ui/api.dart';
|
||||||
import 'package:cdb_ui/main.dart';
|
import 'package:cdb_ui/main.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
class SetupPage extends StatefulWidget {
|
class SetupPage extends StatefulWidget {
|
||||||
|
const SetupPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_SetupPageState createState() => _SetupPageState();
|
_SetupPageState createState() => _SetupPageState();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +19,7 @@ class _SetupPageState extends State<SetupPage> {
|
||||||
|
|
||||||
if (instanceUrl.isEmpty || token.isEmpty) {
|
if (instanceUrl.isEmpty || token.isEmpty) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('Please fill in all fields')),
|
const SnackBar(content: Text('Please fill in all fields')),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -27,14 +28,14 @@ class _SetupPageState extends State<SetupPage> {
|
||||||
|
|
||||||
// Indicate that the setup is complete
|
// Indicate that the setup is complete
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('Setup Complete!')),
|
const SnackBar(content: Text('Setup Complete!')),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Navigate or close the setup screen
|
// Navigate or close the setup screen
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => MyHomePage(),
|
builder: (context) => const MyHomePage(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ class _SetupPageState extends State<SetupPage> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text('Setup Page'),
|
title: const Text('Setup Page'),
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
@ -50,19 +51,19 @@ class _SetupPageState extends State<SetupPage> {
|
||||||
children: [
|
children: [
|
||||||
TextField(
|
TextField(
|
||||||
controller: _urlController,
|
controller: _urlController,
|
||||||
decoration: InputDecoration(labelText: 'Instance URL'),
|
decoration: const InputDecoration(labelText: 'Instance URL'),
|
||||||
keyboardType: TextInputType.url,
|
keyboardType: TextInputType.url,
|
||||||
),
|
),
|
||||||
SizedBox(height: 16.0),
|
const SizedBox(height: 16.0),
|
||||||
TextField(
|
TextField(
|
||||||
controller: _tokenController,
|
controller: _tokenController,
|
||||||
decoration: InputDecoration(labelText: 'Token'),
|
decoration: const InputDecoration(labelText: 'Token'),
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
),
|
),
|
||||||
SizedBox(height: 32.0),
|
const SizedBox(height: 32.0),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: _saveSettings,
|
onPressed: _saveSettings,
|
||||||
child: Text('Complete Setup'),
|
child: const Text('Complete Setup'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -4,9 +4,9 @@ import 'package:qr_bar_code_scanner_dialog/qr_bar_code_scanner_dialog.dart';
|
||||||
|
|
||||||
class SupplyPage extends StatefulWidget {
|
class SupplyPage extends StatefulWidget {
|
||||||
final Item item;
|
final Item item;
|
||||||
Function refresh;
|
final Function refresh;
|
||||||
|
|
||||||
SupplyPage(this.item, this.refresh, {super.key});
|
const SupplyPage(this.item, this.refresh, {super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SupplyPage> createState() => _SupplyPageState();
|
State<SupplyPage> createState() => _SupplyPageState();
|
||||||
|
@ -168,7 +168,7 @@ class _SupplyPageState extends State<SupplyPage> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
width: 12,
|
width: 12,
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|
Loading…
Add table
Reference in a new issue