-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Angelo Cordero
committed
Feb 9, 2023
1 parent
08f1b29
commit fb15081
Showing
8 changed files
with
174 additions
and
41 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
@@ -1,5 +1,41 @@ | ||
import 'package:flutter/painting.dart'; | ||
|
||
import '../models/scripture_reference_model.dart'; | ||
|
||
String scriptureRefToRefString(ScriptureReference ref) { | ||
return '${ref.translation} ${ref.book} ${ref.chapter}:${ref.verse!.verseString}'; | ||
} | ||
|
||
//TODO refactor | ||
int maxCharacters( | ||
String text, | ||
TextStyle style, | ||
) { | ||
final TextPainter heightPainter = TextPainter( | ||
text: TextSpan(text: text, style: style), | ||
maxLines: 1, | ||
textDirection: TextDirection.ltr, | ||
)..layout(minWidth: 0, maxWidth: double.infinity); | ||
|
||
final TextPainter widthPainter = TextPainter( | ||
// M as text because it probably is the widest | ||
text: TextSpan(text: 'M', style: style), | ||
maxLines: 1, | ||
textDirection: TextDirection.ltr, | ||
)..layout(minWidth: 0, maxWidth: double.infinity); | ||
|
||
double height = heightPainter.height; | ||
double paddingSize = 30; | ||
int maxLines = (1080 - (2 * paddingSize) - 100) ~/ height; | ||
|
||
final TextPainter textPainter = TextPainter( | ||
text: TextSpan( | ||
text: text, | ||
style: style, | ||
), | ||
maxLines: maxLines, | ||
textDirection: TextDirection.ltr, | ||
)..layout(minWidth: 0, maxWidth: 1920 - 30 - 30); | ||
|
||
return ((textPainter.width ~/ widthPainter.width) * maxLines) - 5; | ||
} |
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