需求:首页,两个标签之间的切换以及下面内容对应的改变。以及首页的自定义导航栏。
import 'package:flutter/material.dart';
class GFIndexPage extends StatefulWidget {
const GFIndexPage({Key? key}) : super(key: key);
@override
State<GFIndexPage> createState() => _GFIndexPageState();
}
class _GFIndexPageState extends State<GFIndexPage> {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Scaffold(
backgroundColor: const Color(0xff1a1a1a),
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
leading: Padding(
padding: const EdgeInsets.all(10),
child: Transform.translate(
offset: const Offset(50.0,0.0),
child: Transform.scale(
scale: 3.0,
child: Image.asset("images/index/GetFun.png"),
),
),
),
actions: [
IconButton(
icon: Image.asset("images/index/notification.png",width: 25,),
onPressed: () {
},
),
],
bottom: const TabBar(
indicatorSize: TabBarIndicatorSize.tab,
isScrollable: true,
unselectedLabelColor: Colors.white,
dividerColor: Color(0xff737373),
tabAlignment: TabAlignment.start,
tabs: [
Tab(child: Text("推荐",style: TextStyle(fontSize: 16.0),),),
Tab(child: Text("发现",style: TextStyle(fontSize: 16.0),),),
],
),
),
body: TabBarView(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image.asset("images/index/recommendHeader.png"),
],
),
const Center(
child: Text("先不做,以后拿来扩展社交"),
),
],
),
),
);
}
}