添加颜色显示

null_safety
小赖 5 years ago
parent 1830f487d4
commit 3312c161f1

@ -0,0 +1,46 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart';
class ColorObject {
Color color;
String name;
String codeName;
ColorObject({
this.color,
this.name,
this.codeName,
});
}
List<ColorObject> colorObjects = [
ColorObject(
color: Color(0xFF333333),
name: '主要暗色',
codeName: 'kDarkColor',
),
ColorObject(
color: kDarkColor,
name: '文本默认颜色',
codeName: 'kTextColor',
),
ColorObject(
color: Color.fromRGBO(0, 0, 0, 0.65),
name: '次文本颜色',
codeName: 'kTextSubColor',
),
ColorObject(
color: Color(0xFFF6B72D),
name: '主题色',
codeName: 'kPrimaryColor',
),
ColorObject(
color: Color(0xFFFFFFFF),
name: '前景色',
codeName: 'kForegroundColor',
),
ColorObject(
color: Color(0xFFF6F6F6),
name: '背景色',
codeName: 'kBackgroundColor',
),
];

@ -0,0 +1,39 @@
import 'package:flutter/material.dart';
import 'package:example/data/color_object.dart';
import 'package:ansu_ui/ansu_ui.dart';
class ExampleStyleColor extends StatefulWidget {
ExampleStyleColor({Key key}) : super(key: key);
@override
_ExampleStyleColorState createState() => _ExampleStyleColorState();
}
class _ExampleStyleColorState extends State<ExampleStyleColor> {
_buildCard(ColorObject object) {
return Column(
children: [
Text(object.name),
Text(object.codeName),
Card(
color: object.color,
child: SizedBox(height: 50.w, width: double.infinity),
),
SizedBox(height: 16.w),
],
);
}
@override
Widget build(BuildContext context) {
return ASScaffold(
title: 'Color',
body: ListView.builder(
itemBuilder: (context, index) {
return _buildCard(colorObjects[index]);
},
itemCount: colorObjects.length,
),
);
}
}

@ -9,6 +9,7 @@ import 'example_scaffold.dart';
import 'example_button.dart';
import 'example_tab_bar.dart';
import 'example_picker.dart';
import 'example_style_color.dart';
void main() {
runApp(MyApp());
@ -58,6 +59,9 @@ class _MyHomePageState extends State<MyHomePage> {
children: [
Image.asset('assets/logo.webp', height: 50),
SizedBox(height: 16.w),
ASButton.info(
title: '颜色 Style Color',
onPressed: () => Get.to(ExampleStyleColor())),
ASButton.info(
title: '按钮 Button', onPressed: () => Get.to(ExampleButton())),
ASButton.info(

@ -8,7 +8,10 @@ import 'package:flutter/material.dart';
///
/// [controller] see more TabController
class ASTabBar extends StatefulWidget implements PreferredSizeWidget {
///items
final List<String> items;
/// TabController
final TabController controller;
///
@ -30,22 +33,25 @@ class ASTabBar extends StatefulWidget implements PreferredSizeWidget {
class _ASTabBarState extends State<ASTabBar> {
@override
Widget build(BuildContext context) {
return TabBar(
isScrollable: widget.isScrollable,
controller: widget.controller,
tabs: widget.items.map((e) => Tab(text: e)).toList(),
labelStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
unselectedLabelStyle: TextStyle(
fontWeight: FontWeight.normal,
return Align(
alignment: Alignment.center,
child: TabBar(
isScrollable: widget.isScrollable,
controller: widget.controller,
tabs: widget.items.map((e) => Tab(text: e)).toList(),
labelStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
),
unselectedLabelStyle: TextStyle(
fontWeight: FontWeight.normal,
),
labelColor: kTextColor,
unselectedLabelColor: kTextSubColor,
indicatorSize: TabBarIndicatorSize.label,
indicatorPadding: EdgeInsets.zero,
indicator: ASTabIndicator(),
),
labelColor: kTextColor,
unselectedLabelColor: kTextSubColor,
indicatorSize: TabBarIndicatorSize.label,
indicatorPadding: EdgeInsets.zero,
indicator: ASTabIndicator(),
);
}
}

@ -6,6 +6,7 @@ const Color kDarkColor = Color(0xFF333333);
///
const Color kTextColor = kDarkColor;
///
const Color kTextSubColor = Color.fromRGBO(0, 0, 0, 0.65);
///

Loading…
Cancel
Save