Skip to content

Commit

Permalink
feat: tab_view ios top placement
Browse files Browse the repository at this point in the history
fix: ios macos slider not expanding, popup_menu background color, ios filled_button padding
  • Loading branch information
KRTirtho committed Nov 3, 2022
1 parent 2f855fb commit 1f8ce0f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 26 deletions.
3 changes: 2 additions & 1 deletion lib/src/platform_filled_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class PlatformFilledButton extends StatelessWidget with PlatformMixin<Widget> {
disabledColor:
style?.backgroundColor?.resolve({MaterialState.disabled}) ??
CupertinoColors.quaternarySystemFill,
padding: style?.padding?.resolve(allStates),
padding: style?.padding?.resolve(allStates) ??
const EdgeInsets.symmetric(horizontal: 22, vertical: 10),
child: child,
),
),
Expand Down
10 changes: 2 additions & 8 deletions lib/src/platform_popup_menu_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart' hide MacosPulldownButton;
import 'package:platform_ui/platform_ui.dart';
import 'package:platform_ui/src/specific/macos_popup_menu_button.dart';
import 'package:platform_ui/src/utils.dart';
import 'package:collection/collection.dart';

class PlatformPopupMenuItem<T> {
Expand Down Expand Up @@ -37,7 +36,7 @@ class PlatformPopupMenuItem<T> {
onTap: onTap,
enabled: enabled,
height: 45,
textStyle: CupertinoTheme.of(context).textTheme.textStyle,
textStyle: PlatformTheme.of(context).textTheme?.body,
child: child,
);
}
Expand Down Expand Up @@ -145,7 +144,6 @@ class PlatformPopupMenuButton<T> extends StatelessWidget
splashFactory: NoSplash.splashFactory,
dividerColor: CupertinoColors.separator,
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
),
child: Material(
textStyle: PlatformTheme.of(context).textTheme!.body!,
Expand All @@ -171,11 +169,7 @@ class PlatformPopupMenuButton<T> extends StatelessWidget
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
color: Utils.brightnessSpecific(
context,
light: color ?? CupertinoColors.secondarySystemBackground,
dark: color ?? CupertinoColors.darkBackgroundGray,
),
color: color ?? CupertinoTheme.of(context).barBackgroundColor,
constraints: constraints,
child: child,
),
Expand Down
33 changes: 18 additions & 15 deletions lib/src/platform_slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,24 @@ class PlatformSlider extends StatelessWidget with PlatformMixin<Widget> {

@override
Widget ios(BuildContext context) {
return Focus(
autofocus: autofocus,
focusNode: focusNode,
child: MouseRegion(
cursor: mouseCursor,
child: CupertinoSlider(
value: value,
onChanged: onChanged,
onChangeStart: onChangeStart,
onChangeEnd: onChangeEnd,
min: min,
max: max,
divisions: divisions,
activeColor: activeColor,
thumbColor: thumbColor ?? CupertinoColors.white,
return SizedBox(
width: double.infinity,
child: Focus(
autofocus: autofocus,
focusNode: focusNode,
child: MouseRegion(
cursor: mouseCursor,
child: CupertinoSlider(
value: value,
onChanged: onChanged,
onChangeStart: onChangeStart,
onChangeEnd: onChangeEnd,
min: min,
max: max,
divisions: divisions,
activeColor: activeColor,
thumbColor: thumbColor ?? CupertinoColors.white,
),
),
),
);
Expand Down
42 changes: 40 additions & 2 deletions lib/src/platform_tab_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class PlatformTab {
);
}

BottomNavigationBarItem ios(
BottomNavigationBarItem iosNavigation(
BuildContext context,
bool active,
) {
Expand All @@ -97,6 +97,23 @@ class PlatformTab {
);
}

Widget ios(
BuildContext context,
bool active,
) {
final theColor = color ?? PlatformTextTheme.of(context).caption?.color;
final theActiveColor = activeColor ??
Theme.of(context).tabBarTheme.labelColor ??
Theme.of(context).colorScheme.primary;
return Text(
label,
style: PlatformTextTheme.of(context).label?.copyWith(
color: active ? theActiveColor : theColor,
fontSize: (PlatformTextTheme.of(context).label?.fontSize ?? 16) - 2),
overflow: TextOverflow.ellipsis,
);
}

MacosTab macos(
BuildContext context,
bool active,
Expand Down Expand Up @@ -288,9 +305,30 @@ class _PlatformTabViewState extends State<PlatformTabView>

@override
Widget ios(BuildContext context) {
if (widget.isNavigational &&
widget.placement?.ios == PlatformTabbarPlacement.top) {
final widgets = widget.body.values.toList();
final items = widget.body.keys
.mapIndexed((i, e) => e.ios(context, currentIndex == i))
.toList();
return PlatformScaffold(
body: Column(
children: [
CupertinoSlidingSegmentedControl(
children: items.asMap(),
onValueChanged: (value) {
if (value != null) controller.index = value;
},
groupValue: currentIndex,
),
Expanded(child: widgets[currentIndex]),
],
),
);
}
final widgets = widget.body.values.toList();
final items = widget.body.keys
.mapIndexed((i, e) => e.ios(context, currentIndex == i))
.mapIndexed((i, e) => e.iosNavigation(context, currentIndex == i))
.toList();
return CupertinoTabScaffold(
controller: controller.ios,
Expand Down

0 comments on commit 1f8ce0f

Please sign in to comment.