Skip to content

Commit

Permalink
feat(linux): platform back button
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Nov 6, 2022
1 parent 5885032 commit 4bbfa23
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class _MyHomePageState extends State<MyHomePage> {
appBar: PlatformAppBar(
title: PlatformText(widget.title),
automaticallyImplyLeading: true,
leading: const Icon(Icons.flutter_dash_rounded),
leading: const PlatformBackButton(),
actions: [
PlatformIconButton(
icon: const Icon(
Expand Down
21 changes: 20 additions & 1 deletion lib/src/platform_back_button.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:libadwaita/libadwaita.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:platform_ui/platform_ui.dart';

Expand Down Expand Up @@ -32,7 +33,25 @@ class PlatformBackButton extends StatelessWidget with PlatformMixin<Widget> {

@override
Widget linux(BuildContext context) {
return android(context);
return PlatformTooltip(
message: MaterialLocalizations.of(context).backButtonTooltip,
child: Container(
margin: const EdgeInsets.all(10),
child: AdwButton.circular(
onPressed: () {
if (onPressed != null) {
onPressed!();
} else {
Navigator.maybePop(context);
}
},
child: Icon(
Icons.chevron_left_rounded,
color: color,
),
),
),
);
}

@override
Expand Down

0 comments on commit 4bbfa23

Please sign in to comment.