Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YaruWindowTitleBar widget doesn't centre title properly #610

Open
whiskeyPeak opened this issue Feb 10, 2023 · 1 comment
Open

YaruWindowTitleBar widget doesn't centre title properly #610

whiskeyPeak opened this issue Feb 10, 2023 · 1 comment
Assignees
Labels
bug Something isn't working widgets

Comments

@whiskeyPeak
Copy link
Contributor

Might be hard to see but there is a slightly larger gap at the top compared to at the bottom.

Screenshot from 2023-02-10 22-53-08

Repro code:

import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';
import 'package:yaru_widgets/yaru_widgets.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await windowManager.ensureInitialized();
  await YaruWindowTitleBar.ensureInitialized();

  windowManager.setPreventClose(false);

  runApp(
    const MyApp(),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark(),
      debugShowCheckedModeBanner: false,
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return YaruMasterDetailPage(
      appBar: const YaruWindowTitleBar(),
      layoutDelegate: const YaruMasterResizablePaneDelegate(
        initialPaneWidth: 300,
        minPageWidth: 200,
        minPaneWidth: 200,
      ),
      tileBuilder: (context, index, selected) => const YaruMasterTile(
        title: Text("title 1"),
      ),
      pageBuilder: (context, index) => YaruDetailPage(
        appBar: YaruWindowTitleBar(
          title: Center(
            child: Container(
              height: 40,
              color: Colors.grey[800],
            ),
          ),
        ),
      ),
      length: 1,
    );
  }
}


@whiskeyPeak
Copy link
Contributor Author

Ahh, the default height of the appBar is 47px, so if the given height of the container is 40px, then we end up with an odd number of pixel that need to be split in half. Setting the container height to 41 solves this issue.

Though I'd expect flutter to render the position of the container on decimal points like it does everywhere else in the framework...

@Feichtmeier Feichtmeier added bug Something isn't working widgets labels Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working widgets
Projects
None yet
Development

No branches or pull requests

2 participants