-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from sparcs-kaist/feat@design-issue
Resolve #111, 배포 전 디자인 이슈 수정
- Loading branch information
Showing
15 changed files
with
232 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'dart:io'; | ||
import 'dart:ui'; | ||
|
||
import 'package:flutter/rendering.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:otlplus/constants/url.dart'; | ||
import 'package:path_provider/path_provider.dart'; | ||
import 'package:permission_handler/permission_handler.dart'; | ||
import 'package:open_app_file/open_app_file.dart'; | ||
|
||
const MethodChannel _channel = const MethodChannel("org.sparcs.otlplus"); | ||
|
||
Future<void> exportImage(RenderRepaintBoundary boundary) async { | ||
final image = await boundary.toImage(pixelRatio: 3.0); | ||
final byteData = await image.toByteData(format: ImageByteFormat.png); | ||
|
||
writeFile(ShareType.image, byteData?.buffer.asUint8List()); | ||
} | ||
|
||
Future<void> writeFile(ShareType type, Uint8List? bytes) async { | ||
final fileName = | ||
"OTL-${DateTime.now().millisecondsSinceEpoch}.${type == ShareType.image ? 'png' : 'ics'}"; | ||
|
||
if (Platform.isAndroid) { | ||
if (await Permission.storage.request().isGranted) { | ||
switch (type) { | ||
case ShareType.image: | ||
_channel.invokeMethod("writeImageAsBytes", <String, dynamic>{ | ||
"fileName": fileName, | ||
"bytes": bytes, | ||
}); | ||
break; | ||
case ShareType.ical: | ||
final directory = await getExternalStorageDirectory(); | ||
final path = | ||
"${directory?.path ?? '/storage/emulated/0/Android/data/org.sparcs.otlplus/files'}/$fileName"; | ||
File(path).writeAsBytesSync(bytes as List<int>); | ||
OpenAppFile.open(path); | ||
break; | ||
} | ||
} | ||
} else { | ||
final directory = await getApplicationDocumentsDirectory(); | ||
final path = "${directory.path}/$fileName"; | ||
File(path).writeAsBytesSync(bytes as List<int>); | ||
OpenAppFile.open(path); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
double getTextHeight( | ||
BuildContext context, { | ||
required String text, | ||
required TextStyle style, | ||
double maxWidth = double.infinity, | ||
}) { | ||
final TextPainter textPainter = TextPainter( | ||
text: TextSpan(text: text, style: style), | ||
textDirection: TextDirection.ltr, | ||
textScaleFactor: MediaQuery.of(context).textScaleFactor, | ||
)..layout(maxWidth: maxWidth); | ||
return textPainter.size.height; | ||
} | ||
|
||
double singleHeight(BuildContext context, TextStyle style) { | ||
return style.fontSize! * | ||
style.height! * | ||
MediaQuery.of(context).textScaleFactor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.