sendImageOnDesktop static method

dynamic sendImageOnDesktop({
  1. Size? imageSize,
  2. required BuildContext context,
  3. required String imagePath,
  4. String? imageName,
  5. dynamic inputElement,
  6. required String currentConversationShowName,
  7. required dynamic sendImageMessage({
    1. String? imageName,
    2. String? imagePath,
    3. dynamic inputElement,
    }),
})

Implementation

static sendImageOnDesktop({
  Size? imageSize,
  required BuildContext context,
  required String imagePath,
  String? imageName,
  dynamic inputElement,
  required String currentConversationShowName,
  required Function({String? imagePath, String? imageName, dynamic inputElement}) sendImageMessage,
}) async {
  final Size size = imageSize ?? await getImageSize(imagePath);

  TencentCloudChatDesktopPopup.showPopupWindow(
    operationKey: TencentCloudChatPopupOperationKey.sendResourcesOnDesktop,
    context: context,
    isDarkBackground: false,
    width: 500,
    height: min(500, size.height / 2 + 140),
    title: tL10n.sendToSomeChat(currentConversationShowName),
    child: (closeFunc) => Container(
      padding: const EdgeInsets.all(16),
      child: TencentCloudChatThemeWidget(
        build: (context, colorTheme, textStyle) => Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            SizedBox(
              height: min(360, size.height / 2),
              child: InkWell(
                onTap: () {
                  launchUrl(TencentCloudChatPlatformAdapter().isWeb ? Uri.parse(imagePath) : Uri.file(imagePath));
                },
                child: TencentCloudChatPlatformAdapter().isWeb
                    ? Image.network(
                        imagePath,
                        height: min(360, size.height / 2),
                      )
                    : Image.file(
                        File(imagePath),
                        height: min(360, size.height / 2),
                      ),
              ),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              mainAxisSize: MainAxisSize.max,
              children: [
                OutlinedButton(
                    style: ButtonStyle(
                      side: MaterialStateProperty.resolveWith<BorderSide>((Set<MaterialState> states) {
                        return BorderSide(color: colorTheme.dividerColor, width: 1);
                      }),
                    ),
                    onPressed: () {
                      closeFunc();
                    },
                    child: Text(tL10n.cancel)),
                const SizedBox(
                  width: 20,
                ),
                ElevatedButton(
                    onPressed: () {
                      sendImageMessage(
                        imagePath: imagePath,
                        imageName: imageName,
                        inputElement: inputElement,
                      );
                      closeFunc();
                    },
                    child: Text(tL10n.send))
              ],
            ),
          ],
        ),
      ),
    ),
  );
}