Skip to content

Commit

Permalink
(Linux)ノートの共有を削除
Browse files Browse the repository at this point in the history
  • Loading branch information
Npepperlinux committed Dec 12, 2023
1 parent 7a197e8 commit 75add35
Showing 1 changed file with 39 additions and 36 deletions.
75 changes: 39 additions & 36 deletions lib/view/common/misskey_notes/note_modal_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';
import 'dart:ui';

import 'package:auto_route/auto_route.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -127,45 +128,47 @@ class NoteModalSheet extends ConsumerWidget {
.openNoteInOtherAccount(context, targetNote)
.expectFailure(context),
),
ListTile(
leading: const Icon(Icons.share),
title: const Text("ノートを共有"),
onTap: () {
ref.read(noteModalSheetSharingModeProviding.notifier).state = true;
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
Future(() async {
final box = context.findRenderObject() as RenderBox?;
final boundary = noteBoundaryKey.currentContext
?.findRenderObject() as RenderRepaintBoundary;
final image = await boundary.toImage(
pixelRatio: View.of(context).devicePixelRatio,
);
final byteData =
await image.toByteData(format: ImageByteFormat.png);
ref.read(noteModalSheetSharingModeProviding.notifier).state =
false;
if (defaultTargetPlatform != TargetPlatform.linux) ...[
ListTile(
leading: const Icon(Icons.share),
title: const Text("ノートを共有"),
onTap: () {
ref.read(noteModalSheetSharingModeProviding.notifier).state = true;
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
Future(() async {
final box = context.findRenderObject() as RenderBox?;
final boundary = noteBoundaryKey.currentContext
?.findRenderObject() as RenderRepaintBoundary;
final image = await boundary.toImage(
pixelRatio: View.of(context).devicePixelRatio,
);
final byteData =
await image.toByteData(format: ImageByteFormat.png);
ref.read(noteModalSheetSharingModeProviding.notifier).state =
false;

final path =
"${(await getApplicationDocumentsDirectory()).path}${separator}share.png";
final file = File(path);
await file.writeAsBytes(
byteData!.buffer.asUint8List(
byteData.offsetInBytes,
byteData.lengthInBytes,
),
);
final path =
"${(await getApplicationDocumentsDirectory()).path}${separator}share.png";
final file = File(path);
await file.writeAsBytes(
byteData!.buffer.asUint8List(
byteData.offsetInBytes,
byteData.lengthInBytes,
),
);

final xFile = XFile(path, mimeType: "image/png");
await Share.shareXFiles(
[xFile],
text: "https://${account.host}/notes/${targetNote.id}",
sharePositionOrigin:
box!.localToGlobal(Offset.zero) & box.size,
);
final xFile = XFile(path, mimeType: "image/png");
await Share.shareXFiles(
[xFile],
text: "https://${account.host}/notes/${targetNote.id}",
sharePositionOrigin:
box!.localToGlobal(Offset.zero) & box.size,
);
});
});
});
},
),
},
),
],
FutureBuilder(
future: ref
.read(misskeyProvider(account))
Expand Down

0 comments on commit 75add35

Please sign in to comment.