2023-03-11 03:17:34 +00:00
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
2023-01-19 17:50:11 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2023-03-11 03:17:34 +00:00
|
|
|
import '../globals.dart';
|
|
|
|
import '../services/auth_service.dart';
|
2023-01-19 17:50:11 +00:00
|
|
|
|
|
|
|
class StandardAppBar {
|
2023-01-25 18:51:53 +00:00
|
|
|
static AppBar build(BuildContext context, String title,
|
2023-03-11 03:17:34 +00:00
|
|
|
{bool withDrawer = false, List<Widget>? actions}) {
|
|
|
|
final service = getIt<AccountsService>();
|
2023-01-19 17:50:11 +00:00
|
|
|
return AppBar(
|
2023-03-11 03:17:34 +00:00
|
|
|
leading: withDrawer
|
|
|
|
? service.loggedIn
|
|
|
|
? Builder(builder: (context) {
|
|
|
|
return IconButton(
|
|
|
|
onPressed: () {
|
|
|
|
Scaffold.of(context).openDrawer();
|
|
|
|
},
|
|
|
|
icon: CachedNetworkImage(
|
|
|
|
imageUrl: service.currentProfile.avatar));
|
|
|
|
})
|
|
|
|
: null
|
|
|
|
: null,
|
2023-01-25 18:51:53 +00:00
|
|
|
title: Text(
|
|
|
|
title,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
2023-03-11 03:17:34 +00:00
|
|
|
actions: actions,
|
2023-01-19 17:50:11 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|