Skip to content

Commit

Permalink
Disable buttons in native window mode
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jul 22, 2022
1 parent 59c769f commit f2383e9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 46 deletions.
17 changes: 6 additions & 11 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@ class ButterflyApp extends StatelessWidget {
buildWhen: (previous, current) =>
previous.nativeWindowTitleBar != current.nativeWindowTitleBar,
builder: (context, settings) {
windowManager.setTitleBarStyle(settings.nativeWindowTitleBar
? TitleBarStyle.normal
: TitleBarStyle.hidden);
if (!kIsWeb && isWindow()) {
windowManager.setTitleBarStyle(settings.nativeWindowTitleBar
? TitleBarStyle.normal
: TitleBarStyle.hidden);
}
return RepositoryProvider(
create: (context) =>
SyncService(context, context.read<SettingsCubit>()),
Expand All @@ -207,10 +209,6 @@ class ButterflyApp extends StatelessWidget {
}

Widget _buildApp() {
final virtualWindowFrameBuilder =
kIsWeb || (!Platform.isWindows && !Platform.isLinux)
? null
: VirtualWindowFrameInit();
return BlocBuilder<SettingsCubit, ButterflySettings>(
buildWhen: (previous, current) =>
previous.theme != current.theme ||
Expand All @@ -230,10 +228,7 @@ class ButterflyApp extends StatelessWidget {
if (child == null) {
return const Center(child: CircularProgressIndicator());
}
if (kIsWeb || virtualWindowFrameBuilder == null) {
return child;
}
return virtualWindowFrameBuilder(context, child);
return child;
},
darkTheme: ThemeManager.getThemeByName(state.design, dark: true),
));
Expand Down
81 changes: 47 additions & 34 deletions app/lib/views/app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ class PadAppBar extends StatelessWidget with PreferredSizeWidget {
Widget build(BuildContext context) {
var bloc = context.read<DocumentBloc>();
return GestureDetector(onSecondaryTap: () {
if (isWindow()) {
if (!kIsWeb && isWindow()) {
windowManager.popUpWindowMenu();
}
}, onLongPress: () {
if (isWindow()) {
if (!kIsWeb && isWindow()) {
windowManager.popUpWindowMenu();
}
}, child: LayoutBuilder(
Expand Down Expand Up @@ -185,44 +185,57 @@ class PadAppBar extends StatelessWidget with PreferredSizeWidget {
isMobile: false,
)),
]);
if (!kIsWeb && isWindow()) {
if (!kIsWeb &&
isWindow() &&
!context
.read<SettingsCubit>()
.state
.nativeWindowTitleBar) {
return DragToMoveArea(child: title);
}
return title;
})),
actions: [
BlocBuilder<DocumentBloc, DocumentState>(
builder: (context, state) => Row(
children: [
if (!isMobile) ...[
IconButton(
icon: const Icon(
PhosphorIcons.arrowCounterClockwiseLight),
tooltip: AppLocalizations.of(context)!.undo,
onPressed: !bloc.canUndo
? null
: () {
Actions.maybeInvoke<UndoIntent>(
context, UndoIntent(context));
},
),
IconButton(
icon: const Icon(PhosphorIcons.arrowClockwiseLight),
tooltip: AppLocalizations.of(context)!.redo,
onPressed: !bloc.canRedo
? null
: () {
Actions.maybeInvoke<RedoIntent>(
context, RedoIntent(context));
},
),
],
if (isWindow()) ...[
const VerticalDivider(),
const WindowButtons()
]
],
),
builder: (context, state) =>
BlocBuilder<SettingsCubit, ButterflySettings>(
buildWhen: (previous, current) =>
previous.nativeWindowTitleBar !=
current.nativeWindowTitleBar,
builder: (context, settings) => Row(
children: [
if (!isMobile) ...[
IconButton(
icon: const Icon(PhosphorIcons
.arrowCounterClockwiseLight),
tooltip: AppLocalizations.of(context)!.undo,
onPressed: !bloc.canUndo
? null
: () {
Actions.maybeInvoke<UndoIntent>(
context, UndoIntent(context));
},
),
IconButton(
icon: const Icon(
PhosphorIcons.arrowClockwiseLight),
tooltip: AppLocalizations.of(context)!.redo,
onPressed: !bloc.canRedo
? null
: () {
Actions.maybeInvoke<RedoIntent>(
context, RedoIntent(context));
},
),
],
if (isWindow() &&
kIsWeb &&
!settings.nativeWindowTitleBar) ...[
const VerticalDivider(),
const WindowButtons()
]
],
)),
)
]);
},
Expand Down
3 changes: 2 additions & 1 deletion app/lib/views/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ class _WindowButtonsState extends State<WindowButtons> with WindowListener {
@override
@override
Widget build(BuildContext context) {
if (isWindow()) {
if (isWindow() &&
!context.read<SettingsCubit>().state.nativeWindowTitleBar) {
return LayoutBuilder(
builder: (context, constraints) => Padding(
padding: const EdgeInsets.all(8.0),
Expand Down

0 comments on commit f2383e9

Please sign in to comment.