Skip to content

Commit

Permalink
Merge pull request #85 from jpnurmi/tab-icons
Browse files Browse the repository at this point in the history
Add tab icons
  • Loading branch information
jpnurmi authored Sep 22, 2022
2 parents 3e6421a + 49016b8 commit 65fb8bc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
16 changes: 10 additions & 6 deletions lib/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import 'package:context_menu/context_menu.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:lxd_service/lxd_service.dart';
import 'package:lxd_x/lxd_x.dart';
import 'package:movable_tabs/movable_tabs.dart';
import 'package:provider/provider.dart';
import 'package:ubuntu_service/ubuntu_service.dart';

import '../instances/instance_view.dart';
import '../launcher/launcher_wizard.dart';
import '../terminal/terminal_page.dart';
import '../widgets/product_logo.dart';
import 'home_menu.dart';
import 'home_model.dart';

Expand Down Expand Up @@ -64,13 +66,15 @@ class HomePage extends StatelessWidget {
selected: index == model.currentIndex,
onPressed: () => model.currentIndex = index,
onClosed: () => model.closeTab(index),
label: terminal.maybeWhen(
running: (instance, running) => AnimatedBuilder(
animation: running,
builder: (context, child) {
return Text(running.title ?? instance.name);
},
icon: terminal.maybeWhen(
none: () => null,
orElse: () => ProductLogo.asset(
name: terminal.instance?.os,
size: 32,
),
),
label: terminal.maybeWhen(
running: (instance, running) => Text(instance.name),
orElse: () => const Text('Home'),
),
);
Expand Down
26 changes: 14 additions & 12 deletions packages/movable_tabs/lib/src/tab_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,23 @@ class MovableTabButton extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (icon != null)
Padding(
padding: const EdgeInsets.all(8),
child: icon!,
Padding(
padding: const EdgeInsetsDirectional.only(
start: 8,
top: 8,
bottom: 8,
),
if (label != null)
Expanded(
child: Padding(
padding: const EdgeInsets.all(8),
child: Align(
alignment: Alignment.center,
child: label!,
),
child: icon,
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(8),
child: Align(
alignment: Alignment.centerLeft,
child: label!,
),
),
),
if (onClosed != null)
Padding(
padding: const EdgeInsets.all(8),
Expand Down

0 comments on commit 65fb8bc

Please sign in to comment.