| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- import 'package:flutter/material.dart';
- import '../../navigation/bottom_nav_bar.dart';
-
- class NewsScreen extends StatelessWidget {
- const NewsScreen({super.key});
-
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: const Text('资讯'),
- actions: [
- IconButton(
- icon: const Icon(Icons.search),
- onPressed: () {},
- ),
- ],
- ),
- body: ListView.builder(
- padding: const EdgeInsets.all(16),
- itemCount: 10,
- itemBuilder: (context, index) {
- return _buildNewsCard(index);
- },
- ),
- bottomNavigationBar: const BottomNavBar(initialIndex: 1),
- );
- }
-
- Widget _buildNewsCard(int index) {
- final titles = [
- 'Flutter 3.0 新特性详解',
- 'Dart 语言最新更新',
- '移动开发趋势分析',
- '前端框架对比',
- '用户体验设计原则',
- '后端架构最佳实践',
- '数据库性能优化',
- '云原生技术解析',
- '人工智能在移动端的应用',
- '跨平台开发方案比较',
- ];
-
- final subtitles = [
- '深入了解Flutter最新版本的重要更新和改进',
- 'Dart语言的最新特性和优化方向',
- '2024年移动开发的重要趋势和技术方向',
- '主流前端框架的优缺点对比分析',
- '提升应用用户体验的关键设计原则',
- '构建高性能后端服务的最佳实践',
- '数据库查询优化和性能调优技巧',
- '云原生技术在微服务中的应用',
- 'AI技术在移动应用中的创新应用',
- '各种跨平台开发方案的对比和选择',
- ];
-
- final times = [
- '2小时前',
- '5小时前',
- '昨天',
- '2天前',
- '3天前',
- '1周前',
- '1周前',
- '2周前',
- '2周前',
- '1个月前',
- ];
-
- return Card(
- margin: const EdgeInsets.only(bottom: 16),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- child: InkWell(
- onTap: () {},
- borderRadius: BorderRadius.circular(12),
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Container(
- width: 60,
- height: 60,
- decoration: BoxDecoration(
- color: Colors.primaries[index % Colors.primaries.length],
- borderRadius: BorderRadius.circular(8),
- ),
- child: Center(
- child: Text(
- '新闻',
- style: TextStyle(
- color: Colors.white,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- ),
- const SizedBox(width: 16),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- titles[index],
- style: const TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- ),
- const SizedBox(height: 4),
- Text(
- subtitles[index],
- style: TextStyle(
- fontSize: 14,
- color: Colors.grey[600],
- ),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- ),
- ],
- ),
- ),
- ],
- ),
- const SizedBox(height: 12),
- Row(
- children: [
- Icon(
- Icons.schedule,
- size: 14,
- color: Colors.grey[500],
- ),
- const SizedBox(width: 4),
- Text(
- times[index],
- style: TextStyle(
- fontSize: 12,
- color: Colors.grey[500],
- ),
- ),
- const Spacer(),
- IconButton(
- icon: Icon(
- Icons.bookmark_border,
- color: Colors.grey[500],
- ),
- onPressed: () {},
- iconSize: 20,
- ),
- IconButton(
- icon: Icon(
- Icons.share,
- color: Colors.grey[500],
- ),
- onPressed: () {},
- iconSize: 20,
- ),
- ],
- ),
- ],
- ),
- ),
- ),
- );
- }
- }
|