Skip to content

Commit

Permalink
Merge pull request media-kit#495 from ashilkn/center_align_bottom_con…
Browse files Browse the repository at this point in the history
…trols

feat(material-seekbar): Center the seek bar within its parent container for improved tap area
  • Loading branch information
alexmercerind authored Sep 26, 2023
2 parents 0147c76 + 6ccba8d commit 3c899ca
Showing 1 changed file with 45 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1260,54 +1260,56 @@ class MaterialSeekBarState extends State<MaterialSeekBar> {
color: Colors.transparent,
width: constraints.maxWidth,
height: _theme(context).seekBarContainerHeight,
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.bottomLeft,
children: [
Container(
width: constraints.maxWidth,
height: _theme(context).seekBarHeight,
alignment: Alignment.bottomLeft,
color: _theme(context).seekBarColor,
child: Stack(
clipBehavior: Clip.none,
child: Center(
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.bottomLeft,
children: [
Container(
width: constraints.maxWidth,
height: _theme(context).seekBarHeight,
alignment: Alignment.bottomLeft,
children: [
Container(
width: constraints.maxWidth * bufferPercent,
color: _theme(context).seekBarBufferColor,
),
Container(
width: tapped
? constraints.maxWidth * slider
: constraints.maxWidth * positionPercent,
color: _theme(context).seekBarPositionColor,
),
],
color: _theme(context).seekBarColor,
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.bottomLeft,
children: [
Container(
width: constraints.maxWidth * bufferPercent,
color: _theme(context).seekBarBufferColor,
),
Container(
width: tapped
? constraints.maxWidth * slider
: constraints.maxWidth * positionPercent,
color: _theme(context).seekBarPositionColor,
),
],
),
),
),
Positioned(
left: tapped
? (constraints.maxWidth -
_theme(context).seekBarThumbSize / 2) *
slider
: (constraints.maxWidth -
_theme(context).seekBarThumbSize / 2) *
positionPercent,
bottom: -1.0 * _theme(context).seekBarThumbSize / 2 +
_theme(context).seekBarHeight / 2,
child: Container(
width: _theme(context).seekBarThumbSize,
height: _theme(context).seekBarThumbSize,
decoration: BoxDecoration(
color: _theme(context).seekBarThumbColor,
borderRadius: BorderRadius.circular(
_theme(context).seekBarThumbSize / 2,
Positioned(
left: tapped
? (constraints.maxWidth -
_theme(context).seekBarThumbSize / 2) *
slider
: (constraints.maxWidth -
_theme(context).seekBarThumbSize / 2) *
positionPercent,
bottom: -1.0 * _theme(context).seekBarThumbSize / 2 +
_theme(context).seekBarHeight / 2,
child: Container(
width: _theme(context).seekBarThumbSize,
height: _theme(context).seekBarThumbSize,
decoration: BoxDecoration(
color: _theme(context).seekBarThumbColor,
borderRadius: BorderRadius.circular(
_theme(context).seekBarThumbSize / 2,
),
),
),
),
),
],
],
),
),
),
),
Expand Down

0 comments on commit 3c899ca

Please sign in to comment.