Skip to content

Commit

Permalink
refactor: update/add CustomAppBar used with FluentUi widgets (inP…
Browse files Browse the repository at this point in the history
…rogress) #42
  • Loading branch information
PouriaMoradi021 committed Dec 27, 2024
1 parent 859457a commit 53bf572
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 24 deletions.
3 changes: 3 additions & 0 deletions assets/icons/ic_close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/ic_maximize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/ic_minimize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 36 additions & 24 deletions lib/src/core/common/widgets/customized_appbar.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:gui/src/core/utils/gen/assets/assets.gen.dart';
import 'package:window_manager/window_manager.dart';

class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
Expand All @@ -17,31 +19,28 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
height: preferredSize.height,
padding: const EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(
color: Colors.grey[900],
color: Colors.grey,
),
child: Row(
children: [
Expanded(
child: Align(
alignment: AlignmentDirectional.centerStart,
child: Text(
'Linux-like AppBar',
style: TextStyle(color: Colors.white, fontSize: 16),
child: SvgPicture.asset(
Assets.icons.icLogoLight,
),
),
),
Row(
children: [
_AppBarButton(
icon: Icons.remove,
color: Colors.yellow,
_FluentAppBarButton(
icon: "Assets.icons.icClose",
onPressed: () async {
await windowManager.minimize();
},
),
_AppBarButton(
icon: Icons.crop_square,
color: Colors.green,
_FluentAppBarButton(
icon: 'FluentIcons.chrome_restore',
onPressed: () async {
final isMaximized = await windowManager.isMaximized();
if (isMaximized) {
Expand All @@ -51,9 +50,8 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
}
},
),
_AppBarButton(
icon: Icons.close,
color: Colors.red,
_FluentAppBarButton(
icon: 'FluentIcons.chrome_close',
onPressed: () async {
await windowManager.close();
},
Expand All @@ -67,23 +65,37 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
}
}

class _AppBarButton extends StatelessWidget {
const _AppBarButton({
class _FluentAppBarButton extends StatelessWidget {
const _FluentAppBarButton({
required this.icon,
required this.color,
required this.onPressed,
});
final IconData icon;
final Color color;

final String icon;
final VoidCallback onPressed;

@override
Widget build(BuildContext context) {
return IconButton(
icon: Icon(icon, size: 16),
color: color,
onPressed: onPressed,
splashRadius: 20,
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: HoverButton(
onPressed: onPressed,
builder: (context, states) {
final color = states.isHovered
? Colors.red
: Colors.transparent;
return Container(
height: 48,
width: 48,
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(4),
),
child: SvgPicture.asset(icon,),
);
},
),
);
}
}

189 changes: 189 additions & 0 deletions lib/src/core/utils/assets/assets.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions lib/src/core/utils/assets/fonts.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 53bf572

Please sign in to comment.