Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(firebase_ui_oauth): fix OAuth provider buttons paddings (#9991)
- Loading branch information
Showing
4 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/firebase_ui_auth/lib/src/widgets/layout_flow_aware_padding.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'package:flutter/widgets.dart'; | ||
|
||
/// Padding widget that takes into account current layout flow. | ||
/// If nearest ancestor is [Row] (or [Flex] with [Flex.direction] equal to | ||
/// [Axis.horizontal]) – horizontal paddings are ignored. | ||
/// Otherwise vertical paddings are ignored. | ||
class LayoutFlowAwarePadding extends StatelessWidget { | ||
final Widget child; | ||
final EdgeInsets padding; | ||
const LayoutFlowAwarePadding({ | ||
Key? key, | ||
required this.child, | ||
required this.padding, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
Axis? axis; | ||
|
||
context.visitAncestorElements((element) { | ||
if (element.widget is Row) { | ||
axis = Axis.horizontal; | ||
return false; | ||
} else if (element.widget is Column) { | ||
axis = Axis.vertical; | ||
return false; | ||
} else if (element.widget is Flex) { | ||
axis = (element.widget as Flex).direction; | ||
return false; | ||
} | ||
|
||
return true; | ||
}); | ||
|
||
EdgeInsets finalPadding; | ||
|
||
if (axis == null) { | ||
finalPadding = padding; | ||
} else if (axis == Axis.horizontal) { | ||
finalPadding = EdgeInsets.only( | ||
left: padding.left, | ||
right: padding.right, | ||
); | ||
} else { | ||
finalPadding = EdgeInsets.only( | ||
top: padding.top, | ||
bottom: padding.bottom, | ||
); | ||
} | ||
|
||
return Padding( | ||
padding: finalPadding, | ||
child: child, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters