Skip to content

Commit

Permalink
flutter: Add FloatingWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsergio committed Dec 25, 2024
1 parent 1c9aae6 commit 474e771
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/flutter/dart/lib/models/FloatingItem.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class FloatingItem implements ItemWithTitleBar {
}
}

bool showsTitleBar() {
return dropArea.groups.length > 1;
}

@override
void close() {
_groupCountChangedConnection.disconnect();
Expand Down
52 changes: 52 additions & 0 deletions src/flutter/dart/lib/widgets/FloatingWidget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
Author: Sérgio Martins <[email protected]>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <[email protected]> for commercial licensing options.
*/

import 'package:KDDockWidgets/KDDockWidgets.dart';
import 'package:KDDockWidgets/widgets/DropAreaWidget.dart';
import 'package:KDDockWidgets/widgets/PositionedWidget.dart';
import 'package:KDDockWidgets/widgets/TabBarWidget.dart';
import 'package:KDDockWidgets/widgets/TitleBarWidget.dart';
import 'package:KDDockWidgets/widgets/DockWidget.dart';

import 'package:flutter/material.dart';

class FloatingWidget extends StatefulWidget {
final FloatingItem floatingItem;
FloatingWidget(this.floatingItem, {Key? key}) : super(key: key);

@override
State<FloatingWidget> createState() {
return FloatingWidgetState(floatingItem);
}
}

class FloatingWidgetState extends State<FloatingWidget> {
final FloatingItem floatingItem;
FloatingWidgetState(this.floatingItem) {}

Widget buildContents(BuildContext ctx) {
final titleBarWidget = TitleBarWidget(floatingItem.titleBar);
final dropAreaWidget = DropAreaWidget(floatingItem.dropArea);

return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (floatingItem.showsTitleBar()) titleBarWidget,
Expanded(child: dropAreaWidget)
],
);
}

@override
Widget build(BuildContext context) {
return buildContents(context);
}
}

0 comments on commit 474e771

Please sign in to comment.