Skip to content

Commit 0f0d582

Browse files
committed
refactor(ui): keep functionality the same as much as possible but refactor widget tree clean up and styling fixes
1 parent f357b4a commit 0f0d582

4 files changed

Lines changed: 334 additions & 326 deletions

File tree

lib/pages/shopinbit/shopinbit_ticket_detail.dart

Lines changed: 89 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import '../../themes/stack_colors.dart';
1212
import '../../utilities/text_styles.dart';
1313
import '../../utilities/util.dart';
1414
import '../../widgets/background.dart';
15+
import '../../widgets/conditional_parent.dart';
1516
import '../../widgets/custom_buttons/app_bar_icon_button.dart';
16-
import '../../widgets/desktop/desktop_dialog.dart';
1717
import '../../widgets/desktop/desktop_dialog_close_button.dart';
1818
import '../../widgets/desktop/primary_button.dart';
19+
import '../../widgets/dialogs/s_dialog.dart';
1920
import '../../widgets/loading_indicator.dart';
21+
import '../../widgets/rounded_container.dart';
2022
import '../../widgets/rounded_white_container.dart';
2123
import 'shopinbit_offer_view.dart';
2224

@@ -459,24 +461,34 @@ class _ShopInBitTicketDetailState extends ConsumerState<ShopInBitTicketDetail> {
459461
: const SizedBox.shrink();
460462

461463
final chatArea = Expanded(
462-
child: Stack(
463-
children: [
464-
ListView.builder(
465-
reverse: true,
466-
padding: const EdgeInsets.symmetric(vertical: 8),
467-
itemCount: model.messages.length,
468-
itemBuilder: (context, index) {
469-
final message = model.messages[model.messages.length - 1 - index];
470-
return _chatBubble(message, isDesktop);
471-
},
472-
),
473-
if (_loading) const LoadingIndicator(width: 24, height: 24),
474-
],
464+
child: ConditionalParent(
465+
condition: Util.isDesktop,
466+
builder: (child) => RoundedContainer(
467+
padding: .zero,
468+
color: Theme.of(context).extension<StackColors>()!.textFieldActiveBG,
469+
child: child,
470+
),
471+
child: Stack(
472+
children: [
473+
ListView.builder(
474+
reverse: true,
475+
padding: const EdgeInsets.all(8),
476+
itemCount: model.messages.length,
477+
itemBuilder: (context, index) {
478+
final message =
479+
model.messages[model.messages.length - 1 - index];
480+
return _chatBubble(message, isDesktop);
481+
},
482+
),
483+
// TODO: fix loading from locking everything up
484+
if (_loading) const LoadingIndicator(width: 24, height: 24),
485+
],
486+
),
475487
),
476488
);
477489

478490
final inputBar = Container(
479-
padding: EdgeInsets.all(isDesktop ? 16 : 8),
491+
padding: Util.isDesktop ? null : const EdgeInsets.all(8),
480492
decoration: BoxDecoration(
481493
color: Theme.of(context).extension<StackColors>()!.popupBG,
482494
borderRadius: BorderRadius.circular(12),
@@ -509,15 +521,17 @@ class _ShopInBitTicketDetailState extends ConsumerState<ShopInBitTicketDetail> {
509521
onSubmitted: (_) => _sendMessage(),
510522
),
511523
),
512-
IconButton(
513-
onPressed: _sendMessage,
514-
icon: Icon(
515-
Icons.send,
516-
color: Theme.of(
517-
context,
518-
).extension<StackColors>()!.accentColorBlue,
524+
if (!Util.isDesktop) const SizedBox(width: 8),
525+
if (!Util.isDesktop)
526+
IconButton(
527+
onPressed: _sendMessage,
528+
icon: Icon(
529+
Icons.send,
530+
color: Theme.of(
531+
context,
532+
).extension<StackColors>()!.accentColorBlue,
533+
),
519534
),
520-
),
521535
],
522536
),
523537
);
@@ -576,51 +590,63 @@ class _ShopInBitTicketDetailState extends ConsumerState<ShopInBitTicketDetail> {
576590
],
577591
);
578592

579-
if (isDesktop) {
580-
return DesktopDialog(
581-
maxWidth: 600,
582-
maxHeight: 650,
583-
child: Column(
584-
children: [
585-
Row(
586-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
587-
children: [
588-
Padding(
589-
padding: const EdgeInsets.only(left: 32),
590-
child: Text("Request", style: STextStyles.desktopH3(context)),
591-
),
592-
const DesktopDialogCloseButton(),
593-
],
594-
),
595-
Expanded(
596-
child: Padding(
597-
padding: const EdgeInsets.symmetric(
598-
horizontal: 32,
599-
vertical: 8,
593+
return ConditionalParent(
594+
condition: isDesktop,
595+
builder: (child) => SDialog(
596+
contentCanScroll: false,
597+
child: SizedBox(
598+
width: 600,
599+
child: Column(
600+
children: [
601+
Row(
602+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
603+
children: [
604+
Padding(
605+
padding: const EdgeInsets.only(left: 32),
606+
child: Text(
607+
"Request",
608+
style: STextStyles.desktopH3(context),
609+
),
610+
),
611+
const DesktopDialogCloseButton(),
612+
],
613+
),
614+
Expanded(
615+
child: Padding(
616+
padding: const EdgeInsets.only(
617+
left: 32,
618+
right: 32,
619+
bottom: 32,
620+
),
621+
child: child,
600622
),
601-
child: body,
602623
),
603-
),
604-
],
605-
),
606-
);
607-
}
608-
609-
return Background(
610-
child: Scaffold(
611-
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
612-
appBar: AppBar(
613-
leading: AppBarBackButton(
614-
onPressed: () => Navigator.of(context).pop(),
615-
),
616-
title: Text(
617-
model.ticketId ?? "Request",
618-
style: STextStyles.navBarTitle(context),
624+
],
619625
),
620626
),
621-
body: SafeArea(
622-
child: Padding(padding: const EdgeInsets.all(16), child: body),
627+
),
628+
child: ConditionalParent(
629+
condition: !isDesktop,
630+
builder: (child) => Background(
631+
child: Scaffold(
632+
backgroundColor: Theme.of(
633+
context,
634+
).extension<StackColors>()!.background,
635+
appBar: AppBar(
636+
leading: AppBarBackButton(
637+
onPressed: () => Navigator.of(context).pop(),
638+
),
639+
title: Text(
640+
model.ticketId ?? "Request",
641+
style: STextStyles.navBarTitle(context),
642+
),
643+
),
644+
body: SafeArea(
645+
child: Padding(padding: const EdgeInsets.all(16), child: child),
646+
),
647+
),
623648
),
649+
child: body,
624650
),
625651
);
626652
}

0 commit comments

Comments
 (0)