mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
139 lines
5.3 KiB
Dart
139 lines
5.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
|
import 'package:syncrow_web/pages/home/bloc/home_state.dart';
|
|
import 'package:syncrow_web/utils/color_manager.dart';
|
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
|
|
|
import '../pages/auth/model/user_model.dart';
|
|
|
|
class WebAppBar extends StatefulWidget{
|
|
final Widget? title;
|
|
final Widget? centerBody;
|
|
final Widget? rightBody;
|
|
|
|
const WebAppBar({super.key, this.title, this.centerBody, this.rightBody});
|
|
|
|
@override
|
|
State<WebAppBar> createState() => _WebAppBarState();
|
|
}
|
|
|
|
class _WebAppBarState extends State<WebAppBar> with HelperResponsiveLayout {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
bool isSmallScreen = isSmallScreenSize(context);
|
|
bool isHalfMediumScreen = isHafMediumScreenSize(context);
|
|
return BlocBuilder<HomeBloc, HomeState>(builder: (context, state) {
|
|
return Container(
|
|
height: (isSmallScreen || isHalfMediumScreen) ? 130 : 100,
|
|
decoration: const BoxDecoration(color: ColorsManager.secondaryColor),
|
|
padding: const EdgeInsets.all(10),
|
|
child: isSmallScreen || isHalfMediumScreen
|
|
? Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (widget.title != null)
|
|
Align(
|
|
alignment: Alignment.centerLeft,
|
|
child: widget.title!,
|
|
),
|
|
if (widget.centerBody != null)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
child: widget.centerBody,
|
|
),
|
|
if (widget.rightBody != null || HomeBloc.user != null)
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
if (widget.rightBody != null) widget.rightBody!,
|
|
Row(
|
|
children: [
|
|
const SizedBox.square(
|
|
dimension: 40,
|
|
child: CircleAvatar(
|
|
backgroundColor: Colors.white,
|
|
child: SizedBox.square(
|
|
dimension: 35,
|
|
child: CircleAvatar(
|
|
backgroundColor: Colors.grey,
|
|
child: FlutterLogo(),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
if (HomeBloc.user != null)
|
|
Text(
|
|
'${HomeBloc.user!.firstName} ${HomeBloc.user!.lastName}',
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
)
|
|
: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Expanded(
|
|
child: Row(
|
|
children: [
|
|
widget.title!,
|
|
if (widget.centerBody != null)
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 80),
|
|
child: widget.centerBody!,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (widget.rightBody != null)
|
|
Align(
|
|
alignment: Alignment.centerRight,
|
|
child: widget.rightBody,
|
|
),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
const SizedBox.square(
|
|
dimension: 40,
|
|
child: CircleAvatar(
|
|
backgroundColor: Colors.white,
|
|
child: SizedBox.square(
|
|
dimension: 35,
|
|
child: CircleAvatar(
|
|
backgroundColor: Colors.grey,
|
|
child: FlutterLogo(),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
if (HomeBloc.user != null)
|
|
Text(
|
|
'${HomeBloc.user!.firstName} ${HomeBloc.user!.lastName}',
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
});
|
|
}
|
|
}
|