Line data Source code
1 : import 'dart:ui'; 2 : 3 : import 'package:flutter/cupertino.dart'; 4 : import 'package:flutter/material.dart'; 5 : 6 : import '../../convex_bottom_bar.dart'; 7 : import 'blend_image_icon.dart'; 8 : import 'inner_builder.dart'; 9 : 10 : /// Convex shape is fixed center with circle. 11 : class FixedCircleTabStyle extends InnerBuilder { 12 : /// Color used as background of appbar and circle icon. 13 : final Color backgroundColor; 14 : 15 : /// Index of the centered convex shape. 16 : final int convexIndex; 17 : 18 : /// Margin of tab. 19 : final margin = (ACTION_LAYOUT_SIZE - ACTION_INNER_BUTTON_SIZE) / 4; 20 : 21 : /// Create style builder 22 1 : FixedCircleTabStyle( 23 : {List<TabItem> items, 24 : Color activeColor, 25 : Color color, 26 : this.backgroundColor, 27 : this.convexIndex}) 28 1 : : super(items: items, activeColor: activeColor, color: color); 29 : 30 1 : @override 31 : Widget build(BuildContext context, int index, bool active) { 32 2 : if (index == convexIndex) { 33 2 : final item = items[index]; 34 1 : return Container( 35 1 : decoration: BoxDecoration( 36 : shape: BoxShape.circle, 37 1 : color: active ? activeColor : color, 38 : ), 39 : width: ACTION_LAYOUT_SIZE, 40 : height: ACTION_LAYOUT_SIZE, 41 2 : margin: EdgeInsets.all(margin), 42 1 : child: BlendImageIcon( 43 2 : active ? item.activeIcon ?? item.icon : item.icon, 44 : size: ACTION_INNER_BUTTON_SIZE, 45 2 : color: item.blend ? backgroundColor : null, 46 : ), 47 : ); 48 : } 49 2 : var item = items[index]; 50 1 : return Container( 51 1 : padding: EdgeInsets.only(bottom: 2), 52 1 : child: Column( 53 : mainAxisAlignment: MainAxisAlignment.end, 54 1 : children: <Widget>[ 55 1 : BlendImageIcon( 56 1 : active ? item.activeIcon ?? item.icon : item.icon, 57 2 : color: item.blend ? (active ? activeColor : color) : null, 58 : ), 59 1 : Text( 60 1 : item.title, 61 2 : style: TextStyle(color: active ? activeColor : color), 62 : ) 63 : ], 64 : ), 65 : ); 66 : } 67 : 68 1 : @override 69 : bool fixed() { 70 : return true; 71 : } 72 : }