| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- import 'package:electronic_assistant/base/base_page.dart';
- import 'package:electronic_assistant/resource/assets.gen.dart';
- import 'package:electronic_assistant/resource/colors.gen.dart';
- import 'package:electronic_assistant/resource/string.gen.dart';
- import 'package:electronic_assistant/utils/expand.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get.dart';
- import 'controller.dart';
- class HomePage extends BasePage<HomePageController> {
- const HomePage({super.key});
- @override
- Widget? buildBody(BuildContext context) {
- return Stack(
- children: [
- buildBgBox(),
- buildTopGradient(),
- SafeArea(
- child: Column(
- children: [
- Container(
- width: 1.sw,
- padding: const EdgeInsets.all(12).w,
- child: buildOperationBar(),
- ),
- Expanded(
- child: CustomScrollView(
- slivers: [
- SliverToBoxAdapter(
- child: Column(
- children: [
- SizedBox(height: 7.h),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12).w,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Text(StringName.homeTalkRecord.tr,
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 17.sp,
- color: ColorName.primaryTextColor)),
- const Spacer(),
- GestureDetector(
- onTap: () {},
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Text(
- StringName.homeTalkSeeAll.tr,
- style: TextStyle(
- fontSize: 13.sp,
- color: ColorName.secondaryTextColor),
- ),
- SizedBox(
- width: 16.w,
- height: 16.w,
- child: Assets.images.iconHomeTalkArrow
- .image()),
- ],
- ),
- )
- ],
- ),
- ),
- SizedBox(height: 12.h),
- ],
- ),
- ),
- SliverList(
- delegate: SliverChildBuilderDelegate(
- (context, index) {
- return ListTile(
- title: Text('Item $index'),
- );
- },
- childCount: 20, // 列表项的数量
- ),
- ),
- SliverToBoxAdapter(
- child: Container(
- padding: EdgeInsets.all(16),
- color: Colors.green,
- child: Text('尾部', style: TextStyle(color: Colors.white)),
- ),
- ),
- ],
- ))
- ],
- ),
- )
- ],
- );
- }
- Row buildOperationBar() {
- return Row(children: [
- GestureDetector(
- onTap: () {},
- child: Row(
- children: [
- SizedBox(
- width: 0.1.sw,
- height: 0.1.sw,
- child: Assets.images.iconHomeLogged.image()),
- SizedBox(width: 8.w),
- Text(StringName.homeGoLogin.tr,
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 15.sp,
- color: ColorName.primaryTextColor))
- ],
- ),
- ),
- const Spacer(),
- GestureDetector(
- child: DecoratedBox(
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(16),
- ),
- child: Padding(
- padding:
- const EdgeInsets.symmetric(horizontal: 8, vertical: 2).w,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- SizedBox(
- width: 28.w,
- height: 28.w,
- child: Assets.images.iconCharge.image()),
- SizedBox(width: 4.w),
- SizedBox(
- width: 28.w,
- child: Assets.images.iconChargeTxt.image()),
- SizedBox(
- width: 12.w,
- height: 12.w,
- child: Assets.images.iconChargeArrow.image()),
- ],
- ),
- )),
- onTap: () {})
- ]);
- }
- Container buildTopGradient() {
- return Container(
- width: 1.sw,
- height: 0.4444444444444444.sw,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: ['#E8EBFF'.toColor(), '#00E8EBFF'.toColor()],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- stops: const [0.3, 1.0],
- ),
- ) // 其他子小部件
- );
- }
- DecoratedBox buildBgBox() {
- return DecoratedBox(
- decoration: BoxDecoration(color: '#F6F6F6'.toColor()),
- child: Container(
- height: double.infinity,
- ));
- }
- }
|