import 'package:cdb_ui/api.dart'; import 'package:cdb_ui/pages/transaction.dart'; import 'package:flutter/material.dart'; class LocationsPage extends StatelessWidget { const LocationsPage({super.key}); @override Widget build(BuildContext context) { // todo : add locations tree view return const Scaffold(); } } class LocationView extends StatefulWidget { final Location location; const LocationView(this.location, {super.key}); @override State createState() => _LocationViewState(); } class _LocationViewState extends State { bool recursive = true; void refresh() { setState(() {}); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.location.name), ), body: Column( children: [ Card( child: Column( children: [ if (widget.location.parent != null) Text("Inside: ${widget.location.parent!}"), if (widget.location.conditions?.temperature != null) Text( "Temperature: ${widget.location.conditions!.temperature} C°") ], ), ), Row( children: [ Checkbox( value: !recursive, onChanged: (bool? newValue) { setState(() { recursive = !(newValue ?? false); }); }, ), const Expanded( child: Text( 'Show only exact matches with location', style: TextStyle(fontSize: 16), ), ), ], ), FutureBuilder( future: API().getTransactionsOfLocation(widget.location.id, recursive: recursive), builder: (context, snapshot) { if (!snapshot.hasData) { return const CircularProgressIndicator(); } var data = snapshot.data!; return ListView( children: data.map((x) => TransactionCard(x, refresh)).toList()); }, ) ], ), ); } }