88 lines
2.9 KiB
Dart
Raw Normal View History

2025-08-03 12:56:13 +07:00
import 'package:enaklo_pos/core/components/spaces.dart';
2025-07-31 19:25:45 +07:00
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
2025-08-04 13:15:03 +07:00
import 'package:enaklo_pos/presentation/home/bloc/current_outlet/current_outlet_bloc.dart';
2025-08-03 12:56:13 +07:00
import 'package:enaklo_pos/presentation/home/dialog/outlet_dialog.dart';
2025-07-30 22:38:44 +07:00
import 'package:flutter/material.dart';
2025-08-04 13:15:03 +07:00
import 'package:flutter_bloc/flutter_bloc.dart';
2025-07-30 22:38:44 +07:00
import '../../../core/components/search_input.dart';
import '../../../core/constants/colors.dart';
class HomeTitle extends StatelessWidget {
final TextEditingController controller;
final Function(String value)? onChanged;
const HomeTitle({
super.key,
required this.controller,
this.onChanged,
});
@override
Widget build(BuildContext context) {
2025-07-31 19:25:45 +07:00
return Container(
height: context.deviceHeight * 0.1,
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
decoration: BoxDecoration(
2025-07-31 23:22:34 +07:00
color: AppColors.white,
2025-07-31 19:25:45 +07:00
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
2025-08-03 12:56:13 +07:00
GestureDetector(
onTap: () => showDialog(
context: context,
builder: (context) => OutletDialog(),
),
2025-08-04 13:15:03 +07:00
child: BlocBuilder<CurrentOutletBloc, CurrentOutletState>(
builder: (context, state) {
return Row(
children: [
state.maybeWhen(
orElse: () => const Text(
'DEFAULT OUTLET',
style: TextStyle(
color: AppColors.primary,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
loading: () => Center(
child: SizedBox(
height: 16,
width: 16,
child: CircularProgressIndicator(
color: AppColors.primary,
),
),
),
loaded: (outlet) => Text(
outlet.name ?? 'DEFAULT OUTLET',
style: TextStyle(
color: AppColors.primary,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
),
SpaceWidth(2),
Icon(Icons.keyboard_arrow_down, color: AppColors.primary),
],
);
},
2025-07-31 23:22:34 +07:00
),
2025-07-31 19:25:45 +07:00
),
SizedBox(
2025-08-04 13:15:03 +07:00
width: context.deviceWidth * 0.2,
2025-07-31 19:25:45 +07:00
child: SearchInput(
controller: controller,
onChanged: onChanged,
hintText: 'Search..',
2025-07-30 22:38:44 +07:00
),
),
2025-07-31 19:25:45 +07:00
],
),
2025-07-30 22:38:44 +07:00
);
}
}