Prechádzať zdrojové kódy

added properties for titles and captions on TitleBarWidget

ashilkn 2 rokov pred
rodič
commit
ff53ff79f7
1 zmenil súbory, kde vykonal 38 pridanie a 22 odobranie
  1. 38 22
      lib/ui/components/title_bar_widget.dart

+ 38 - 22
lib/ui/components/title_bar_widget.dart

@@ -2,8 +2,19 @@ import 'package:flutter/material.dart';
 import 'package:photos/theme/ente_theme.dart';
 
 class TitleBarWidget extends StatelessWidget {
+  final String? title;
+  final String? caption;
+  final Widget? flexibleSpaceTitle;
+  final String? flexibleSpaceCaption;
   final List<Widget>? actionIcons;
-  const TitleBarWidget({this.actionIcons, super.key});
+  const TitleBarWidget({
+    this.title,
+    this.caption,
+    this.flexibleSpaceTitle,
+    this.flexibleSpaceCaption,
+    this.actionIcons,
+    super.key,
+  });
 
   @override
   Widget build(BuildContext context) {
@@ -19,16 +30,20 @@ class TitleBarWidget extends StatelessWidget {
         crossAxisAlignment: CrossAxisAlignment.start,
         mainAxisAlignment: MainAxisAlignment.start,
         children: [
-          Text(
-            'Title',
-            style: getEnteTextTheme(context).largeBold,
-          ),
-          Text(
-            'Caption',
-            style: getEnteTextTheme(context)
-                .mini
-                .copyWith(color: getEnteColorScheme(context).textMuted),
-          )
+          title == null
+              ? const SizedBox.shrink()
+              : Text(
+                  title!,
+                  style: getEnteTextTheme(context).largeBold,
+                ),
+          caption == null
+              ? const SizedBox.shrink()
+              : Text(
+                  caption!,
+                  style: getEnteTextTheme(context)
+                      .mini
+                      .copyWith(color: getEnteColorScheme(context).textMuted),
+                )
         ],
       ),
       actions: [
@@ -56,17 +71,18 @@ class TitleBarWidget extends StatelessWidget {
             mainAxisAlignment: MainAxisAlignment.end,
             crossAxisAlignment: CrossAxisAlignment.start,
             mainAxisSize: MainAxisSize.min,
-            children: [
-              Text(
-                'Title',
-                style: getEnteTextTheme(context).h3Bold,
-              ),
-              Text(
-                'Caption',
-                style: getEnteTextTheme(context)
-                    .small
-                    .copyWith(color: getEnteColorScheme(context).textMuted),
-              )
+            children: <Widget>[
+              flexibleSpaceTitle == null
+                  ? const SizedBox.shrink()
+                  : flexibleSpaceTitle!,
+              flexibleSpaceCaption == null
+                  ? const SizedBox.shrink()
+                  : Text(
+                      'Caption',
+                      style: getEnteTextTheme(context).small.copyWith(
+                            color: getEnteColorScheme(context).textMuted,
+                          ),
+                    )
             ],
           ),
         ),