Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
fe7c5b65e8 | |||
40afd685dd | |||
dd9a61bcca | |||
ca98d86e26 | |||
89658791bb |
|
@ -5,7 +5,6 @@ steps:
|
||||||
- name: build
|
- name: build
|
||||||
image: cirrusci/flutter:latest
|
image: cirrusci/flutter:latest
|
||||||
commands:
|
commands:
|
||||||
- flutter doctor
|
|
||||||
- flutter build apk --release
|
- flutter build apk --release
|
||||||
- name: gitea_release
|
- name: gitea_release
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
|
@ -13,7 +12,8 @@ steps:
|
||||||
api_key:
|
api_key:
|
||||||
from_secret: gitea_api_key
|
from_secret: gitea_api_key
|
||||||
base_url: https://git.lat
|
base_url: https://git.lat
|
||||||
|
draft: true
|
||||||
files: build/app/outputs/apk/release/app-release.apk
|
files: build/app/outputs/apk/release/app-release.apk
|
||||||
trigger:
|
when:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
25
.vscode/launch.json
vendored
Normal file
25
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
// Verwendet IntelliSense zum Ermitteln möglicher Attribute.
|
||||||
|
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
|
||||||
|
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "f0ckapp",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "f0ckapp (profile mode)",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"flutterMode": "profile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "f0ckapp (release mode)",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"flutterMode": "release"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
15
lib/api/fetchitem.dart
Normal file
15
lib/api/fetchitem.dart
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import 'package:f0ckapp/model/item.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
|
Future<Item> fetchItemFromApi(id) async {
|
||||||
|
final response = await http.get(Uri.parse('https://f0ck.dev/api/v2/item/$id'));
|
||||||
|
|
||||||
|
if(response.statusCode == 200) {
|
||||||
|
//List jsonresponse = json.decode(response.body)['rows'];
|
||||||
|
Map<String, dynamic> jsonresponse = json.decode(response.body)['rows'];
|
||||||
|
return Item.fromJson(jsonresponse);
|
||||||
|
} else {
|
||||||
|
throw Exception('failed to load feed');
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,28 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:f0ckapp/view/home.dart';
|
import 'package:f0ckapp/view/home.dart';
|
||||||
|
import 'package:f0ckapp/view/item.dart';
|
||||||
|
|
||||||
void main() {
|
/*void main() {
|
||||||
runApp(MaterialApp(
|
runApp(MaterialApp(
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
scaffoldBackgroundColor: const Color.fromARGB(255, 23, 23, 23)
|
scaffoldBackgroundColor: const Color.fromARGB(255, 23, 23, 23)
|
||||||
),
|
),
|
||||||
home: const Home()
|
home: const Home()
|
||||||
));
|
));
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void main() async {
|
||||||
|
runApp(
|
||||||
|
MaterialApp(
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
initialRoute: '/',
|
||||||
|
theme: ThemeData(
|
||||||
|
scaffoldBackgroundColor: const Color.fromARGB(255, 23, 23, 23)
|
||||||
|
),
|
||||||
|
routes: {
|
||||||
|
'/': (context) => const Home(),
|
||||||
|
'/detail': (context) => const ItemPage(id: 0),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,21 @@ class Item {
|
||||||
int id;
|
int id;
|
||||||
String mime;
|
String mime;
|
||||||
int tagId;
|
int tagId;
|
||||||
|
String dest;
|
||||||
|
|
||||||
Item({
|
Item({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.mime,
|
required this.mime,
|
||||||
required this.tagId
|
this.tagId = 0,
|
||||||
|
this.dest = ''
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Item.fromJson(Map<String, dynamic> data) {
|
factory Item.fromJson(Map<String, dynamic> data) {
|
||||||
return Item(
|
return Item(
|
||||||
id: data['id'],
|
id: data['id'],
|
||||||
mime: data['mime'],
|
mime: data['mime'],
|
||||||
tagId: data['tag_id']
|
tagId: data['tag_id'] ?? 0,
|
||||||
|
dest: data['dest'] ?? ''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:f0ckapp/api/fetchdata.dart';
|
import 'package:f0ckapp/api/fetchdata.dart';
|
||||||
import 'package:f0ckapp/model/item.dart';
|
import 'package:f0ckapp/model/item.dart';
|
||||||
|
import 'package:f0ckapp/view/item.dart';
|
||||||
|
|
||||||
class Home extends StatefulWidget {
|
class Home extends StatefulWidget {
|
||||||
const Home({Key? key}) : super(key: key);
|
const Home({Key? key}) : super(key: key);
|
||||||
|
@ -19,6 +20,13 @@ class _HomeState extends State<Home> {
|
||||||
f0cks = fetchDataFromApi();
|
f0cks = fetchDataFromApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future loadf0cks() {
|
||||||
|
setState(() {
|
||||||
|
f0cks = fetchDataFromApi();
|
||||||
|
});
|
||||||
|
return f0cks;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -31,8 +39,14 @@ class _HomeState extends State<Home> {
|
||||||
body: FutureBuilder<List<Item>>(
|
body: FutureBuilder<List<Item>>(
|
||||||
future: f0cks,
|
future: f0cks,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if(snapshot.hasData) {
|
if(!snapshot.hasData) {
|
||||||
return CustomScrollView(
|
return Text("${snapshot.error}");
|
||||||
|
}
|
||||||
|
return RefreshIndicator(
|
||||||
|
onRefresh: () {
|
||||||
|
return loadf0cks();
|
||||||
|
},
|
||||||
|
child: CustomScrollView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
slivers: <Widget>[
|
slivers: <Widget>[
|
||||||
SliverGrid(
|
SliverGrid(
|
||||||
|
@ -49,7 +63,16 @@ class _HomeState extends State<Home> {
|
||||||
case 2: mode = Colors.red; break;
|
case 2: mode = Colors.red; break;
|
||||||
default: mode = Colors.yellow; break;
|
default: mode = Colors.yellow; break;
|
||||||
}
|
}
|
||||||
return Stack(
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ItemPage(id: snapshot.data![index].id),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Stack(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Image.network("https://f0ck.dev/t/${snapshot.data?[index].id}.webp"),
|
Image.network("https://f0ck.dev/t/${snapshot.data?[index].id}.webp"),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
@ -66,17 +89,15 @@ class _HomeState extends State<Home> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
childCount: snapshot.data?.length
|
childCount: snapshot.data?.length
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
} else if(snapshot.hasError) {
|
|
||||||
return Text("${snapshot.error}");
|
|
||||||
}
|
|
||||||
return const CircularProgressIndicator();
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
58
lib/view/item.dart
Normal file
58
lib/view/item.dart
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
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"),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user