This commit is contained in:
JMARyA 2024-09-15 17:49:50 +02:00
parent b6a46673cf
commit 5f5487803b
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
4 changed files with 35 additions and 35 deletions

View file

@ -1,15 +1,13 @@
import 'package:cdb_ui/api.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'supply.dart';
class ConsumePage extends StatefulWidget {
final String item;
final String variant;
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});
@override

View file

@ -26,7 +26,7 @@ class _ItemViewState extends State<ItemView> {
),
body: Column(children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 28),
padding: const EdgeInsets.symmetric(horizontal: 28),
child: Column(
children: [
Row(
@ -39,7 +39,7 @@ class _ItemViewState extends State<ItemView> {
fallbackHeight: 100,
),
), // todo
SizedBox(
const SizedBox(
width: 16.0,
),
Column(
@ -60,13 +60,13 @@ class _ItemViewState extends State<ItemView> {
return Column(children: [
Text(
entry.value.name,
style: TextStyle(fontWeight: FontWeight.bold),
style: const TextStyle(fontWeight: FontWeight.bold),
),
FutureBuilder(
future: API().getStat(widget.item.id, entry.key),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return CircularProgressIndicator();
return const CircularProgressIndicator();
}
var stat = snapshot.data!;
@ -82,7 +82,7 @@ class _ItemViewState extends State<ItemView> {
)
]);
}).toList()),
SizedBox(
const SizedBox(
height: 12,
)
],
@ -115,9 +115,9 @@ class _ItemViewState extends State<ItemView> {
class TransactionCard extends StatelessWidget {
final Transaction t;
Function refresh;
final Function refresh;
TransactionCard(this.t, this.refresh, {super.key});
const TransactionCard(this.t, this.refresh, {super.key});
@override
Widget build(BuildContext context) {
@ -131,13 +131,13 @@ class TransactionCard extends StatelessWidget {
},
child: Card(
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(
borderRadius: BorderRadius.circular(10),
),
elevation: 4,
child: Padding(
padding: EdgeInsets.all(12),
padding: const EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -148,9 +148,9 @@ class TransactionCard extends StatelessWidget {
children: [
Text(
t.item,
style: TextStyle(fontSize: 16),
style: const TextStyle(fontSize: 16),
),
SizedBox(
const SizedBox(
width: 4,
),
Text(
@ -165,25 +165,26 @@ class TransactionCard extends StatelessWidget {
),
],
),
SizedBox(
const SizedBox(
height: 10,
),
Row(
children: [
Icon(Icons.money, size: 18, color: Colors.green),
SizedBox(width: 6),
const Icon(Icons.money, size: 18, color: Colors.green),
const SizedBox(width: 6),
Text(
"${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) ...[
SizedBox(height: 8),
const SizedBox(height: 8),
Row(
children: [
Icon(Icons.store, size: 18, color: Colors.blue),
SizedBox(width: 6),
const Icon(Icons.store, size: 18, color: Colors.blue),
const SizedBox(width: 6),
Text(
t.origin!,
style: TextStyle(fontSize: 14, color: Colors.grey[700]),

View file

@ -1,9 +1,10 @@
import 'package:cdb_ui/api.dart';
import 'package:cdb_ui/main.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class SetupPage extends StatefulWidget {
const SetupPage({super.key});
@override
_SetupPageState createState() => _SetupPageState();
}
@ -18,7 +19,7 @@ class _SetupPageState extends State<SetupPage> {
if (instanceUrl.isEmpty || token.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Please fill in all fields')),
const SnackBar(content: Text('Please fill in all fields')),
);
return;
}
@ -27,14 +28,14 @@ class _SetupPageState extends State<SetupPage> {
// Indicate that the setup is complete
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Setup Complete!')),
const SnackBar(content: Text('Setup Complete!')),
);
// Navigate or close the setup screen
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => MyHomePage(),
builder: (context) => const MyHomePage(),
));
}
@ -42,7 +43,7 @@ class _SetupPageState extends State<SetupPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Setup Page'),
title: const Text('Setup Page'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
@ -50,19 +51,19 @@ class _SetupPageState extends State<SetupPage> {
children: [
TextField(
controller: _urlController,
decoration: InputDecoration(labelText: 'Instance URL'),
decoration: const InputDecoration(labelText: 'Instance URL'),
keyboardType: TextInputType.url,
),
SizedBox(height: 16.0),
const SizedBox(height: 16.0),
TextField(
controller: _tokenController,
decoration: InputDecoration(labelText: 'Token'),
decoration: const InputDecoration(labelText: 'Token'),
obscureText: true,
),
SizedBox(height: 32.0),
const SizedBox(height: 32.0),
ElevatedButton(
onPressed: _saveSettings,
child: Text('Complete Setup'),
child: const Text('Complete Setup'),
),
],
),

View file

@ -4,9 +4,9 @@ import 'package:qr_bar_code_scanner_dialog/qr_bar_code_scanner_dialog.dart';
class SupplyPage extends StatefulWidget {
final Item item;
Function refresh;
final Function refresh;
SupplyPage(this.item, this.refresh, {super.key});
const SupplyPage(this.item, this.refresh, {super.key});
@override
State<SupplyPage> createState() => _SupplyPageState();
@ -168,7 +168,7 @@ class _SupplyPageState extends State<SupplyPage> {
},
),
),
SizedBox(
const SizedBox(
width: 12,
),
IconButton(