轮播图实现
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/components/BannerCarousel.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/features/my/presentation/bloc/my_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/my/repository/my_repository.dart';
|
||||
@@ -68,36 +69,12 @@ class MyPage extends StatelessWidget {
|
||||
|
||||
Widget _buildBanner(BuildContext context) {
|
||||
// 添加 context 参数
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => WebViewPage(url: 'https://www.satabot.com/')));
|
||||
},
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 160,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
image: DecorationImage(image: NetworkImage('https://c.53326.com/d/file/lan20221010/fyhj0ibovbp.jpg'), fit: BoxFit.cover),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
top: 12,
|
||||
right: 12,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(color: Colors.black.withOpacity(0.5), borderRadius: BorderRadius.circular(4)),
|
||||
child: Text('了解我们', style: TextStyle(color: Colors.white, fontSize: 14)),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 12,
|
||||
bottom: 12,
|
||||
child: Text('AI赋能农业', style: TextStyle(color: Colors.white, fontSize: 16)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
return BannerCarousel(
|
||||
items: [
|
||||
BannerItem(image: 'https://c.53326.com/d/file/lan20221010/fyhj0ibovbp.jpg', title: 'AI赋能农业', url: 'https://www.satabot.com/'),
|
||||
BannerItem(image: 'https://picsum.photos/800/400?1', title: '智能农机上新', url: 'https://www.satabot.com/'),
|
||||
BannerItem(image: 'https://picsum.photos/800/400?2', title: '科技改变生活', url: 'https://www.satabot.com/'),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user