Skip to content

Commit

Permalink
chore: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
appflowy committed Dec 30, 2024
1 parent 90ad6e2 commit f5adaa0
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,42 +27,19 @@ class _AIMessageMetadataState extends State<AIMessageMetadata> {

@override
Widget build(BuildContext context) {
final sourceCount = widget.sources.length;

return AnimatedSize(
duration: 150.milliseconds,
alignment: AlignmentDirectional.topStart,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const VSpace(8.0),
ConstrainedBox(
constraints: const BoxConstraints(
maxHeight: 24,
maxWidth: 240,
),
child: FlowyButton(
margin: const EdgeInsets.all(4.0),
useIntrinsicWidth: true,
hoverColor: Colors.transparent,
radius: BorderRadius.circular(8.0),
text: FlowyText(
LocaleKeys.chat_referenceSource.plural(
widget.sources.length,
namedArgs: {'count': '${widget.sources.length}'},
),
fontSize: 12,
color: Theme.of(context).hintColor,
),
rightIcon: FlowySvg(
isExpanded ? FlowySvgs.arrow_up_s : FlowySvgs.arrow_down_s,
size: const Size.square(10),
),
onTap: () {
setState(() => isExpanded = !isExpanded);
},
),
),
_buildHeader(context, sourceCount),
if (isExpanded) ...[
const VSpace(4.0),
<<<<<<< Updated upstream
Wrap(
spacing: 8.0,
runSpacing: 4.0,
Expand Down Expand Up @@ -95,9 +72,116 @@ class _AIMessageMetadataState extends State<AIMessageMetadata> {
},
).toList(),
),
=======
_buildSourceButtons(),
>>>>>>> Stashed changes
],
],
),
);
}

Widget _buildHeader(BuildContext context, int sourceCount) {
return ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 24, maxWidth: 240),
child: FlowyButton(
margin: const EdgeInsets.all(4.0),
useIntrinsicWidth: true,
hoverColor: Colors.transparent,
radius: BorderRadius.circular(8.0),
text: FlowyText(
LocaleKeys.chat_referenceSource.plural(
sourceCount,
namedArgs: {'count': '$sourceCount'},
),
fontSize: 12,
color: Theme.of(context).hintColor,
),
rightIcon: FlowySvg(
isExpanded ? FlowySvgs.arrow_up_s : FlowySvgs.arrow_down_s,
size: const Size.square(10),
),
onTap: () => setState(() => isExpanded = !isExpanded),
),
);
}

Widget _buildSourceButtons() {
return Wrap(
spacing: 8.0,
runSpacing: 4.0,
children: widget.sources.map((source) => _buildMetadataButton(source)).toList(),
);
}

Widget _buildMetadataButton(ChatMessageRefSource source) {
if (isURL(source.id)) {
return _MetadataButton(
name: source.id,
onTap: () => widget.onSelectedMetadata?.call(source),
);
} else if (isUUID(source.id)) {
return FutureBuilder<ViewPB?>(
future: ViewBackendService.getView(source.id).then((f) => f.toNullable()),
builder: (context, snapshot) {
if (!snapshot.hasData || snapshot.connectionState != ConnectionState.done) {
return _MetadataButton(name: source.name);
}
final data = snapshot.data!;
return BlocProvider(
create: (_) => ViewBloc(view: data),
child: BlocBuilder<ViewBloc, ViewState>(
builder: (context, state) {
return _MetadataButton(
name: state.view.nameOrDefault,
onTap: () => widget.onSelectedMetadata?.call(source),
);
},
),
);
},
);
} else {
return _MetadataButton(
name: source.name,
onTap: () => widget.onSelectedMetadata?.call(source),
);
}
}
}
<<<<<<< Updated upstream
=======

class _MetadataButton extends StatelessWidget {
const _MetadataButton({
required this.name,
this.onTap,
});

final String name;
final void Function()? onTap;

@override
Widget build(BuildContext context) {
return ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 24, maxWidth: 240),
child: FlowyButton(
margin: const EdgeInsets.all(4.0),
useIntrinsicWidth: true,
radius: BorderRadius.circular(8.0),
text: FlowyText(
name,
fontSize: 12,
overflow: TextOverflow.ellipsis,
),
leftIcon: FlowySvg(
FlowySvgs.icon_document_s,
size: const Size.square(16),
color: Theme.of(context).hintColor,
),
onTap: onTap,
),
);
}
}
>>>>>>> Stashed changes
22 changes: 11 additions & 11 deletions frontend/rust-lib/flowy-sqlite/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ diesel::table! {
}

diesel::allow_tables_to_appear_in_same_query!(
af_collab_metadata,
chat_local_setting_table,
chat_message_table,
chat_table,
collab_snapshot,
upload_file_part,
upload_file_table,
user_data_migration_records,
user_table,
user_workspace_table,
workspace_members_table,
af_collab_metadata,
chat_local_setting_table,
chat_message_table,
chat_table,
collab_snapshot,
upload_file_part,
upload_file_table,
user_data_migration_records,
user_table,
user_workspace_table,
workspace_members_table,
);

0 comments on commit f5adaa0

Please sign in to comment.