fda
This commit is contained in:
parent
3983d553a9
commit
4a8288c907
@ -5,7 +5,7 @@ import 'collectionpage_controller.dart';
|
||||
class CollectionPageBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => CollectionPageController());
|
||||
Get.put(CollectionPageController());
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,7 +5,7 @@ import 'downloadpage_controller.dart';
|
||||
class DownloadPageBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => DownloadPageController());
|
||||
Get.put( DownloadPageController());
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,7 +5,8 @@ import 'homepage_controller.dart';
|
||||
class HomePageBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => HomePageController());
|
||||
// Get.lazyPut(() => HomePageController());
|
||||
Get.put(HomePageController());
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,5 +1,25 @@
|
||||
import 'package:get/get.dart';
|
||||
import "package:wallpaper/utils/assettool.dart";
|
||||
|
||||
class HomePageController extends GetxController {
|
||||
var typeList = [].obs;
|
||||
|
||||
@override
|
||||
void onReady() async{
|
||||
super.onReady();
|
||||
|
||||
setupTypeListData();
|
||||
}
|
||||
|
||||
void setupTypeListData() async{
|
||||
var temData = await loadWallpaperJsonFromAsset();
|
||||
temData.forEach((element) { })
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,48 +4,50 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:transparent_image/transparent_image.dart';
|
||||
import 'package:wallpaper/pages/homepage/homepage_controller.dart';
|
||||
|
||||
class HomePageView extends GetView {
|
||||
class HomePageView extends GetView <HomePageController> {
|
||||
const HomePageView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Get.put(HomePageController);
|
||||
const title = "壁纸";
|
||||
final SizedBox headerView = getHeaderWidget(context);
|
||||
final GridView bodyView = getBodyWidget();
|
||||
|
||||
return MaterialApp(
|
||||
title: title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text(title),
|
||||
),
|
||||
body: Row(
|
||||
children: [
|
||||
headerView,
|
||||
// bodyView,
|
||||
],
|
||||
),
|
||||
),
|
||||
// final SizedBox headerView = getHeaderWidget(context);
|
||||
final Widget bodyView = getBodyWidget();
|
||||
|
||||
// Obx(() => {
|
||||
// print(controller.typeList);
|
||||
// return Text("data");}
|
||||
// );
|
||||
print("build......hompage");
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text(title),
|
||||
),
|
||||
// body: Row(
|
||||
// children: [
|
||||
// headerView,
|
||||
// // bodyView,
|
||||
// ],
|
||||
body:bodyView,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
//返回内容
|
||||
GridView getBodyWidget(){
|
||||
return GridView.count(
|
||||
// Create a grid with 2 columns. If you change the scrollDirection to
|
||||
// horizontal, this produces 2 rows.
|
||||
Widget getBodyWidget(){
|
||||
return Obx(() => GridView.count(
|
||||
crossAxisCount: 2,
|
||||
// Generate 100 widgets that display their index in the List.
|
||||
children: List.generate(100, (index) {
|
||||
children: List.generate(controller.typeList.length, (index) {
|
||||
return Center(
|
||||
child: FadeInImage.memoryNetwork(
|
||||
placeholder: kTransparentImage,
|
||||
image: 'https://picsum.photos/250?image=9',
|
||||
image: controller.typeList[index]["data"][0]["previewThumb"],
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
//初始化顶部数据
|
||||
@ -75,14 +77,31 @@ class HomePageView extends GetView {
|
||||
width: cw,
|
||||
color: Colors.yellow,
|
||||
),
|
||||
Container(
|
||||
width: cw,
|
||||
color: Colors.orange,
|
||||
),
|
||||
getCustomContrainer("cuainer"),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//customcontainer
|
||||
Container getCustomContrainer(String title) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
// decoration: BoxDecoration( //用于设置边框
|
||||
// border: Border.all(color: Colors.black12, width: 0.5),
|
||||
// borderRadius: BorderRadius.all(Radius.circular(5.0))),
|
||||
color:Colors.red,
|
||||
padding: EdgeInsets.all(5.0),
|
||||
// margin: EdgeInsets.fromLTRB(3.0, 0.0, 3.0, 0.0),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: 100.0,),
|
||||
child: Text(
|
||||
title,
|
||||
softWrap: true,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,7 +5,7 @@ import 'mypage_controller.dart';
|
||||
class MyPageBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => MyPageController());
|
||||
Get.put(() => MyPageController());
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,9 +7,7 @@ class MyPageView extends GetView {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const title = '我的';
|
||||
return MaterialApp(
|
||||
title: title,
|
||||
home: Scaffold(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text(title),
|
||||
),
|
||||
@ -29,7 +27,7 @@ class MyPageView extends GetView {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,7 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:wallpaper/pages/homePage/homePage_view.dart';
|
||||
import 'package:wallpaper/pages/downloadpage/downloadpage_view.dart';
|
||||
import 'package:wallpaper/pages/collectionpage/collectionpage_view.dart';
|
||||
import 'package:wallpaper/pages/mypage/mypage_view.dart';
|
||||
|
||||
@ -41,10 +39,6 @@ class TabbarPageView extends GetView <TabbarPageController>{
|
||||
icon: Icon(Icons.collections),
|
||||
label: "收藏"
|
||||
),
|
||||
// const BottomNavigationBarItem(
|
||||
// icon: Icon(Icons.download),
|
||||
// label: "下载"
|
||||
// ),
|
||||
const BottomNavigationBarItem(
|
||||
icon: Icon(Icons.person),
|
||||
label: "我的"
|
||||
|
||||
@ -24,31 +24,7 @@ class AppRoutes {
|
||||
GetPage(
|
||||
name: initialPage,
|
||||
page: ()=> const TabbarPageView(),
|
||||
binding: TabbarPageBinding(),
|
||||
participatesInRootNavigator: true,
|
||||
),
|
||||
GetPage(
|
||||
name: '/home',
|
||||
page: ()=> const HomePageView(),
|
||||
binding: HomePageBinding(),
|
||||
participatesInRootNavigator: true,
|
||||
),
|
||||
GetPage(
|
||||
name: '/downlaod',
|
||||
page: ()=> const DownloadPageView(),
|
||||
binding: DownloadPageBinding(),
|
||||
participatesInRootNavigator: true,
|
||||
),
|
||||
GetPage(
|
||||
name: '/collection',
|
||||
page: ()=> const CollectionPageView(),
|
||||
binding: CollectionPageBinding(),
|
||||
participatesInRootNavigator: true,
|
||||
),
|
||||
GetPage(
|
||||
name: '/my',
|
||||
page: ()=> const MyPageView(),
|
||||
binding: MyPageBinding(),
|
||||
bindings: [TabbarPageBinding(), HomePageBinding(),DownloadPageBinding(),MyPageBinding()],
|
||||
participatesInRootNavigator: true,
|
||||
),
|
||||
];
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import 'package:flutter/services.dart' show rootBundle;
|
||||
import 'dart:convert';
|
||||
Future<Map<String, dynamic>> loadWallpaperJsonFromAsset() async {
|
||||
Future<List> loadWallpaperJsonFromAsset() async {
|
||||
String jsonStr = await rootBundle.loadString('assets/wallpaper.json');
|
||||
return jsonDecode(jsonStr);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user