59 lines
1.7 KiB
Dart
59 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:f0ckapp/model/item.dart';
|
|
import 'package:f0ckapp/api/fetchitem.dart';
|
|
|
|
class ItemPage extends StatefulWidget {
|
|
final int id;
|
|
const ItemPage({Key? key, required this.id }) : super(key: key);
|
|
|
|
@override
|
|
// ignore: library_private_types_in_public_api
|
|
_ItemPageState createState() => _ItemPageState();
|
|
}
|
|
|
|
class _ItemPageState extends State<ItemPage> with SingleTickerProviderStateMixin {
|
|
late final int id;
|
|
late Future<Item> f0ck;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
id = widget.id;
|
|
f0ck = fetchItemFromApi(id);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FutureBuilder<Item>(
|
|
future: f0ck,
|
|
builder: (context, snapshot) {
|
|
if(!snapshot.hasData) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
final deviceSize = MediaQuery.of(context).size;
|
|
//final aspectRatio = widget.item.width / widget.item.height;
|
|
//final containerHeight = deviceSize.width / aspectRatio;
|
|
|
|
return RefreshIndicator(
|
|
onRefresh: () {
|
|
return fetchItemFromApi(id);
|
|
},
|
|
child: SingleChildScrollView(
|
|
physics: const AlwaysScrollableScrollPhysics(),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
SizedBox(
|
|
width: deviceSize.width,
|
|
height: 550,//containerHeight,
|
|
child: snapshot.data!.mime.startsWith('image') ? Image.network("https://f0ck.dev/b/${snapshot.data?.dest}") : const Text("no image"),
|
|
)
|
|
]
|
|
)
|
|
)
|
|
);
|
|
}
|
|
);
|
|
}
|
|
}
|