muh :(
This commit is contained in:
parent
7d1f000a43
commit
71a5668d90
|
@ -51,6 +51,7 @@ android {
|
|||
targetSdkVersion flutter.targetSdkVersion
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
minSdkVersion 19
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.f0ckapp">
|
||||
<application
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.f0ckapp">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<application
|
||||
android:label="f0ckapp"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
|
|
14
lib/api/fetchdata.dart
Normal file
14
lib/api/fetchdata.dart
Normal file
|
@ -0,0 +1,14 @@
|
|||
import 'package:f0ckapp/model/item.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
Future<List<Item>> fetchDataFromApi() async {
|
||||
final response = await http.get(Uri.parse('https://f0ck.dev/api/v2/items/get?mode=3'));
|
||||
|
||||
if(response.statusCode == 200) {
|
||||
List jsonresponse = json.decode(response.body)['items'];
|
||||
return jsonresponse.map((tmp) => Item.fromJson(tmp)).toList();
|
||||
} else {
|
||||
throw Exception('failed to load feed');
|
||||
}
|
||||
}
|
|
@ -1,29 +1,19 @@
|
|||
class Item {
|
||||
int id;
|
||||
String mime;
|
||||
int tagId;
|
||||
|
||||
Item({
|
||||
required this.id,
|
||||
required this.mime,
|
||||
required this.tagId
|
||||
});
|
||||
final int id;
|
||||
final String mime;
|
||||
final int tagId;
|
||||
|
||||
factory Item.fromJson(Map<String, dynamic> data) {
|
||||
final id = data['id'] as int;
|
||||
final mime = data['mime'] as String;
|
||||
final tagId = data['tag_id'] as int;
|
||||
return Item(
|
||||
id: id,
|
||||
mime: mime,
|
||||
tagId: tagId
|
||||
id: data['id'],
|
||||
mime: data['mime'],
|
||||
tagId: data['tag_id']
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'mime': mime,
|
||||
'tagId': tagId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:f0ckapp/api/fetchdata.dart';
|
||||
|
||||
import 'package:image_network/image_network.dart';
|
||||
|
||||
import 'package:f0ckapp/model/item.dart';
|
||||
|
||||
|
@ -14,22 +16,12 @@ class Home extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _HomeState extends State<Home> {
|
||||
List data = [];
|
||||
List<Item> f0cks = <Item>[];
|
||||
late Future<List<Item>> f0cks;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
fetchDataFromApi();
|
||||
}
|
||||
|
||||
Future<bool> fetchDataFromApi() async {
|
||||
final jsondata = await http.get(Uri.parse('https://f0ck.dev/api/v2/items/get?mode=3'));
|
||||
final list = json.decode(jsondata.body)['items'] as List<dynamic>;
|
||||
setState(() {
|
||||
f0cks = list.map((e) => Item.fromJson(e)).toList();
|
||||
});
|
||||
return true;
|
||||
f0cks = fetchDataFromApi();
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -41,41 +33,74 @@ class _HomeState extends State<Home> {
|
|||
title: const Text('f0cks'),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: GridView.builder(
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3
|
||||
),
|
||||
itemCount: f0cks.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
|
||||
Color mode;
|
||||
switch(f0cks[index].tagId) {
|
||||
case 1: mode = Colors.green; break;
|
||||
case 2: mode = Colors.red; break;
|
||||
default: mode = Colors.yellow; break;
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Image.network("https://f0ck.dev/t/${f0cks[index].id}.webp"),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: FractionalOffset.bottomRight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 5.0, right: 5.0),
|
||||
child: Icon(
|
||||
Icons.square,
|
||||
color: mode,
|
||||
size: 20.0
|
||||
),
|
||||
body: FutureBuilder<List<Item>>(
|
||||
future: f0cks,
|
||||
builder: (context, snapshot) {
|
||||
if(snapshot.hasData) {
|
||||
return CustomScrollView(
|
||||
shrinkWrap: true,
|
||||
slivers: <Widget>[
|
||||
SliverGrid(
|
||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 130.0,
|
||||
mainAxisSpacing: 2,
|
||||
crossAxisSpacing: 2,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
Color mode;
|
||||
switch(snapshot.data?[index].tagId) {
|
||||
case 1: mode = Colors.green; break;
|
||||
case 2: mode = Colors.red; break;
|
||||
default: mode = Colors.yellow; break;
|
||||
}
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
ImageNetwork(
|
||||
image: "https://f0ck.dev/t/${snapshot.data?[index].id}.webp",
|
||||
imageCache: CachedNetworkImageProvider("https://f0ck.dev/t/${snapshot.data?[index].id}.webp"),
|
||||
height: 128,
|
||||
width: 128,
|
||||
duration: 1500,
|
||||
curve: Curves.easeIn,
|
||||
onPointer: true,
|
||||
fitAndroidIos: BoxFit.cover,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
onError: const Icon(
|
||||
Icons.error,
|
||||
color: Colors.red,
|
||||
),
|
||||
onTap: () {
|
||||
debugPrint(snapshot.data?[index].mime);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: FractionalOffset.bottomRight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 0, right: 0),
|
||||
child: Icon(
|
||||
Icons.square,
|
||||
color: mode,
|
||||
size: 15.0
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
},
|
||||
childCount: snapshot.data?.length
|
||||
)
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
},
|
||||
),
|
||||
]
|
||||
);
|
||||
} else if(snapshot.hasError) {
|
||||
return Text("${snapshot.error}");
|
||||
}
|
||||
return const CircularProgressIndicator();
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import path_provider_macos
|
||||
import sqflite
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||
}
|
||||
|
|
241
pubspec.lock
241
pubspec.lock
|
@ -15,6 +15,27 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
cached_network_image:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cached_network_image
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.2.1"
|
||||
cached_network_image_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cached_network_image_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
cached_network_image_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cached_network_image_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -43,6 +64,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.16.0"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -57,11 +85,39 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.1.2"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_blurhash:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_blurhash
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.7.0"
|
||||
flutter_cache_manager:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_cache_manager
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.3.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
|
@ -87,7 +143,14 @@ packages:
|
|||
name: http_parser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.0.0"
|
||||
version: "4.0.1"
|
||||
image_network:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: image_network
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.5.1"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -116,6 +179,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
octo_image:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: octo_image
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -123,6 +193,97 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
path_provider:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.10"
|
||||
path_provider_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.14"
|
||||
path_provider_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_ios
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.9"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.7"
|
||||
path_provider_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.6"
|
||||
path_provider_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.4"
|
||||
path_provider_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.11.1"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
pointer_interceptor:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pointer_interceptor
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.9.3+1"
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: process
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.2.4"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: rxdart
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.27.3"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
@ -135,6 +296,20 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.2"
|
||||
sqflite:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sqflite
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.2+1"
|
||||
sqflite_common:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sqflite_common
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.1+1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -156,6 +331,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
synchronized:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: synchronized
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.0+2"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -177,6 +359,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: uuid
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.6"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -184,5 +373,55 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
webview_flutter:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.8.0"
|
||||
webview_flutter_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.8.9"
|
||||
webview_flutter_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
webview_flutter_wkwebview:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_wkwebview
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.8.0"
|
||||
webviewimage:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webviewimage
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.7.0"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.0+1"
|
||||
sdks:
|
||||
dart: ">=2.17.0 <3.0.0"
|
||||
flutter: ">=3.0.0"
|
||||
|
|
|
@ -15,10 +15,10 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 1.0.0+1
|
||||
version: 1.0.1+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.17.0 <3.0.0"
|
||||
sdk: ">=2.17.0 <3.1.0"
|
||||
|
||||
# Dependencies specify other packages that your package needs in order to work.
|
||||
# To automatically upgrade your package dependencies to the latest versions
|
||||
|
@ -31,6 +31,8 @@ dependencies:
|
|||
sdk: flutter
|
||||
http: ^0.13.4
|
||||
cupertino_icons: ^1.0.2
|
||||
image_network: ^2.5.1
|
||||
cached_network_image: ^3.2.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:f0ckapp/main.dart';
|
||||
import 'package:f0ckapp/view/home.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(const MyApp());
|
||||
await tester.pumpWidget(const Home());
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
|
|
Loading…
Reference in New Issue
Block a user