You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.4 KiB
87 lines
2.4 KiB
4 years ago
|
import 'package:ansu_ui/ansu_ui.dart';
|
||
4 years ago
|
import 'package:example/codeviewer/code_segments.dart';
|
||
|
import 'package:example/common/code_view.dart';
|
||
4 years ago
|
import 'package:flutter/material.dart';
|
||
4 years ago
|
import 'package:get/get.dart';
|
||
4 years ago
|
|
||
|
class ExampleTabBar extends StatefulWidget {
|
||
|
ExampleTabBar({Key key}) : super(key: key);
|
||
|
|
||
|
@override
|
||
|
_ExampleTabBarState createState() => _ExampleTabBarState();
|
||
|
}
|
||
|
|
||
|
class _ExampleTabBarState extends State<ExampleTabBar>
|
||
|
with TickerProviderStateMixin {
|
||
|
TabController _tabController1;
|
||
|
TabController _tabController2;
|
||
|
TabController _tabController3;
|
||
4 years ago
|
TabController _tabController4;
|
||
4 years ago
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
_tabController1 = TabController(length: 3, vsync: this);
|
||
|
_tabController2 = TabController(length: 5, vsync: this);
|
||
|
_tabController3 = TabController(length: 10, vsync: this);
|
||
4 years ago
|
_tabController4 = TabController(length: 10, vsync: this);
|
||
4 years ago
|
}
|
||
|
|
||
|
@override
|
||
|
void dispose() {
|
||
|
_tabController1?.dispose();
|
||
|
_tabController2?.dispose();
|
||
|
_tabController3?.dispose();
|
||
4 years ago
|
_tabController4?.dispose();
|
||
4 years ago
|
super.dispose();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return ASScaffold(
|
||
4 years ago
|
title: '选项卡 TabBar',
|
||
4 years ago
|
actions: [
|
||
|
IconButton(
|
||
|
icon: Icon(
|
||
|
Icons.code,
|
||
|
color: Colors.black54,
|
||
|
),
|
||
|
onPressed: () => Get.to(
|
||
|
CodeView(text: (context) => CodeSegments.tabBar(context)),
|
||
|
),
|
||
|
)
|
||
|
],
|
||
4 years ago
|
body: Material(
|
||
|
color: kForegroundColor,
|
||
4 years ago
|
child: Column(
|
||
4 years ago
|
mainAxisSize: MainAxisSize.min,
|
||
4 years ago
|
children: [
|
||
4 years ago
|
// BEGIN tabBar
|
||
4 years ago
|
ASTabBar(
|
||
|
items: ['全部', 'Part1', 'Part2'],
|
||
|
controller: _tabController1,
|
||
|
),
|
||
|
ASTabBar(
|
||
|
items: List.generate(5, (index) => 'Tab $index'),
|
||
|
controller: _tabController2,
|
||
|
),
|
||
|
ASTabBar(
|
||
|
isScrollable: true,
|
||
|
items: List.generate(10, (index) => 'Tab $index'),
|
||
|
controller: _tabController3,
|
||
|
),
|
||
4 years ago
|
ASTabBar.tag(
|
||
|
isScrollable: true,
|
||
|
tabItems: List.generate(10, (index) => 'Tab $index')
|
||
|
.map((e) => ASTabBarItem(title: e, tag: e))
|
||
|
.toList(),
|
||
|
controller: _tabController4,
|
||
|
),
|
||
4 years ago
|
|
||
|
// END
|
||
4 years ago
|
],
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|