bare implementation of comuncation with the api
All checks were successful
Build and push docker image / Build (pull_request) Successful in 2m6s
Build and release APK / Build APK (pull_request) Successful in 4m32s

This commit is contained in:
2024-08-01 22:48:28 +02:00
parent 016622c7af
commit 5748630b99
5 changed files with 94 additions and 39 deletions

View File

@@ -20,26 +20,40 @@ class Greeter extends StatefulWidget {
class _GreeterState extends State<Greeter> {
Widget greeterBuild (BuildContext context, AsyncSnapshot<Trip> snapshot) {
ThemeData theme = Theme.of(context);
String cityName = "";
Widget topGreeter;
if (snapshot.hasData) {
cityName = snapshot.data?.cityName ?? '...';
topGreeter = Padding(
padding: const EdgeInsets.only(top: 20, bottom: 20),
child: Text(
'Welcome to ${snapshot.data?.cityName}!',
style: TextStyle(color: theme.primaryColor, fontWeight: FontWeight.bold, fontSize: 24),
)
);
} else if (snapshot.hasError) {
cityName = "error";
} else { // still awaiting the cityname
cityName = "...";
topGreeter = const Padding(
padding: EdgeInsets.only(top: 20, bottom: 20),
child: Text('Error while fetching trip')
);
} else {
// still awaiting the cityname
// Show a linear loader at the bottom and an info message above
topGreeter = Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.only(top: 20, bottom: 20),
child: const Text('Generating your trip...', style: TextStyle(fontSize: 20),)
),
const LinearProgressIndicator()
]
);
}
Widget topGreeter = Text(
'Welcome to $cityName!',
style: TextStyle(color: theme.primaryColor, fontWeight: FontWeight.bold, fontSize: 24),
);
if (widget.standalone) {
return Center(
child: Padding(
padding: EdgeInsets.only(top: 24.0),
child: topGreeter,
),
child: topGreeter,
);
} else {
return Center(