Browse Source

排版首页样式

ios
王子贤 2 months ago
parent
commit
87ab2effc8
8 changed files with 211 additions and 6 deletions
  1. BIN
      assets/images/star_sky_bg.png
  2. BIN
      assets/images/test1.png
  3. BIN
      assets/images/test2.png
  4. 9
      lib/components/sphere_cloud.dart
  5. 45
      lib/controller/home/real_home_controller.dart
  6. 3
      lib/generated/assets.dart
  7. 155
      lib/pages/home/real_home_page.dart
  8. 5
      lib/pages/main/main_page.dart

BIN
assets/images/star_sky_bg.png

Before After
Width: 1500  |  Height: 4405  |  Size: 3.9 MiB

BIN
assets/images/test1.png

Before After
Width: 682  |  Height: 334  |  Size: 98 KiB

BIN
assets/images/test2.png

Before After
Width: 682  |  Height: 334  |  Size: 88 KiB

9
lib/components/sphere_cloud.dart

@ -1,14 +1,15 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class SphereCloud extends StatefulWidget {
const SphereCloud({
SphereCloud({
super.key,
required this.items,
this.radius = 140,
this.itemSize = 48,
this.cameraZ = 400, //
this.focal = 240, //
required this.itemSize,
this.cameraZ = 360, //
this.focal = 320, //
this.minScale = 0.45,
this.maxScale = 1.25,
});

45
lib/controller/home/real_home_controller.dart

@ -0,0 +1,45 @@
import 'package:dating_touchme_app/model/home/marriage_data.dart';
import 'package:dating_touchme_app/network/home_api.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class RealHomeController extends GetxController {
late final HomeApi _homeApi;
//
final recommendFeed = <MarriageData>[].obs;
@override
void onInit() {
super.onInit();
// HomeApi
_homeApi = Get.find<HomeApi>();
getListData();
}
getListData() async {
try {
var response = await _homeApi.getMarriageList(
pageNum: 1,
pageSize: 100,
type: 0,
);
if (response.data.isSuccess) {
final allRecords = response.data.data!.records
.map((item) => MarriageData.fromJson(item as Map<String, dynamic>))
.toList();
//
final records = allRecords!.where((item) => !item.isLive).toList();
recommendFeed.addAll(records);
update();
} else {
//
throw Exception(response.data.message);
}
} catch(e) {
//
rethrow;
}
}
}

3
lib/generated/assets.dart

@ -198,12 +198,15 @@ class Assets {
static const String imagesSplash = 'assets/images/splash.png';
static const String imagesSquareNol = 'assets/images/square_nol.png';
static const String imagesSquarePre = 'assets/images/square_pre.png';
static const String imagesStarSkyBg = 'assets/images/star_sky_bg.png';
static const String imagesSubscript = 'assets/images/subscript.png';
static const String imagesSuccessIcon = 'assets/images/success_icon.png';
static const String imagesTabChangeIcon = 'assets/images/tab_change_icon.png';
static const String imagesTalkIcon = 'assets/images/talk_icon.png';
static const String imagesTeenagerBg = 'assets/images/teenager_bg.png';
static const String imagesTeenagerList = 'assets/images/teenager_list.png';
static const String imagesTest1 = 'assets/images/test1.png';
static const String imagesTest2 = 'assets/images/test2.png';
static const String imagesUnreadIcon = 'assets/images/unread_icon.png';
static const String imagesUpdataBg = 'assets/images/updata_bg.png';
static const String imagesUpdataFont = 'assets/images/updata_font.png';

155
lib/pages/home/real_home_page.dart

@ -0,0 +1,155 @@
import 'package:dating_touchme_app/components/page_appbar.dart';
import 'package:dating_touchme_app/components/sphere_cloud.dart';
import 'package:dating_touchme_app/controller/home/real_home_controller.dart';
import 'package:dating_touchme_app/generated/assets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
class RealHomePage extends StatefulWidget {
const RealHomePage({super.key});
@override
State<RealHomePage> createState() => _RealHomePageState();
}
class _RealHomePageState extends State<RealHomePage> with AutomaticKeepAliveClientMixin {
@override
Widget build(BuildContext context) {
super.build(context);
return GetBuilder<RealHomeController>(
init: RealHomeController(),
builder: (controller){
return Stack(
children: [
Image.asset(
Assets.imagesStarSkyBg,
width: 375.w,
fit: BoxFit.cover,
alignment: AlignmentGeometry.topCenter,
),
Scaffold(
backgroundColor: Colors.transparent,
appBar: PageAppbar(title: "快乐星球", color: Colors.white, backgroundColor: Colors.transparent,),
body: Container(
width: 375.w,
padding: EdgeInsets.symmetric(horizontal: 15.w),
child: SingleChildScrollView(
child: Column(
children: [
SizedBox(
width: 345.w,
height: 345.w,
child: SphereCloud(
itemSize: 36.w,
items: [
...controller.recommendFeed.map((e){
return SizedBox(
width: 36.w,
child: Column(
children: [
Text(
e.nickName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.w,
color: Colors.white,
fontWeight: FontWeight.w400
),
),
Image.network(
e.profilePhoto,
width: 18.w,
height: 18.w,
fit: BoxFit.cover,
)
],
),
);
}),
]
),
),
Container(
width: 92.w,
height: 21.w,
margin: EdgeInsets.symmetric(vertical: 20.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(21.w)),
color: const Color.fromRGBO(255, 255, 255, .1)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.autorenew,
size: 18.w,
color: Colors.white,
),
SizedBox(width: 4.w,),
Text(
"换一批",
style: TextStyle(
fontSize: 12.w,
color: Colors.white
),
)
],
),
),
Row(
children: [
Text(
"趣味测试",
style: TextStyle(
fontSize: 16.w,
color: Colors.white
),
)
],
),
SizedBox(height: 7.w,),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset(
Assets.imagesTest1,
width: 170.w,
),
Image.asset(
Assets.imagesTest2,
width: 170.w,
),
],
),
SizedBox(height: 15.w,),
Row(
children: [
Text(
"热门帖子",
style: TextStyle(
fontSize: 16.w,
color: Colors.white
),
)
],
),
SizedBox(height: 7.w,),
],
),
),
),
)
],
);
},
);
}
@override
bool get wantKeepAlive => true;
}

5
lib/pages/main/main_page.dart

@ -1,5 +1,6 @@
import 'package:dating_touchme_app/extension/ex_widget.dart';
import 'package:dating_touchme_app/generated/assets.dart';
import 'package:dating_touchme_app/pages/home/real_home_page.dart';
import 'package:dating_touchme_app/pages/home/send_timeline.dart';
import 'package:dating_touchme_app/pages/home/timeline_page.dart';
import 'package:dating_touchme_app/pages/home/timeline_window.dart';
@ -34,7 +35,7 @@ class _MainPageState extends State<MainPage> {
int currentIndex = 0; // 使int替代RxInt
// build都重新创建
late HomePage homePage;
late RealHomePage homePage;
late DiscoverPage discoverPage;
late TimelinePage timelinePage;
late MessagePage messagePage;
@ -45,7 +46,7 @@ class _MainPageState extends State<MainPage> {
super.initState();
//
homePage = HomePage();
homePage = RealHomePage();
// discoverPage = DiscoverPage();
timelinePage = TimelinePage();
messagePage = MessagePage();

Loading…
Cancel
Save