When I configure a Text widget with a maximum of 1 line and an overflow set to ellipsis, the widget shows correctly.
Text(
"Last summer, I was working on a prototype for an AR app that would allow users to create
virtual objects in real world spaces. I carried out the work using the Unity3D game engine.
My last commit to the repository was five months ago.",
maxLines: 1,
overflow: TextOverflow.ellipsis
)
However, when I set the maximum number of lines to any number higher than 1, the
number of lines is limited correctly, but the overflow ellipsis does not show.
Text(
"Last summer, I was working on a prototype for an AR app that would allow users to create
virtual objects in real world spaces. I carried out the work using the Unity3D game engine.
My last commit to the repository was five months ago.",
maxLines: 2,
overflow: TextOverflow.ellipsis
)
How can I configure the Text widget to show the overflow ellipsis when more than one line is set for maxLines?
Find below code , it might help you.
Text(
"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
overflow: TextOverflow.ellipsis,
maxLines: 5,
),
In your example, the maximum lines is 3 but the text just show 2 lines of text. It means you dont provide enough height for maximum lines (like the height of it's container).
So you can provide more space for it or reduce maximum lines to 2 or place the text widget in Flex widgets (like ListView, ...)
You can test this one to see what i mean for
Container(
height: 100,
child: Text(
"Last summer, I was working on a prototype for an AR app that would allow users to create virtual objects in real world spaces. I carried out the work using the Unity3D game engine. My last commit to the repository was five months ago.",
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
),
Related
I'm trying to generate dynamic pdf, using pdf dependency in flutter. I want the pdf to be generated based on text content, current it is limiting to only one page and dynamically not creating a second page or dynamically increasing the size of pages. The following is my code.
var data = await rootBundle.load("fonts/OpenSans-Regular.ttf");
final ttf = pw.Font.ttf(data);
pdf.addPage(
pw.Page(
theme: pw.ThemeData.withFont(
base: ttf,
),
// pageFormat: PdfPageFormat.undefined,
build: (pw.Context context) {
return pw.Paragraph(
text:
"What is Lorem Ipsum?\nLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.\n\nWhy do we use it?\nIt is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).\n\nWhere does it come from?\nContrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of 'de Finibus Bonorum et Malorum' (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum,'Lorem ipsum dolor sit amet..', comes from a line in section 1.10.32.\nThe standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et Malorum by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.;\n\nWhere can I get some?\nThere are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc."); // Center
},
),
);
final appDocDir = await getApplicationDocumentsDirectory();
final appDocPath = appDocDir.path;
final file = File(appDocPath + '/' + 'dummy.pdf');
print('Save as file ${file.path} ...');
await file.writeAsBytes(await pdf.save());
Please look at the following screenshot. Please help me ...
Try adding Multipage like this,
pdf.addPage(
pw.MultiPage(
...)
)
instead of
pdf.addPage(
pw.Page(
...)
)
Is there any way I can have a document or PDF stored on my swift application file and edit select predefined fields inside the document/pdf using swift code?
For example the document/pdf would contain the following fields i'd like to amend; [INPUT1], [INPUT2], [INPUT3]
"What is [INPUT1] Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the [INPUT2], when an unknown printer
took a galley of type and scrambled it to make a type [INPUT3] book.
It has survived not only five centuries, but also the leap into
electronic typesetting, remaining essentially unchanged."
In swift I would like to ask the user 3 questions and have their answers replace [INPUT1], [INPUT2], [INPUT3] respectively.
If not possible to edit word/pdf file is there any other way to achieve this while being able to keep the formatting of the text mentioned above while only changing the mentioned fields.
Thanks again for your help!
Look into implementing PDFKit and see this answer how to implement pdf editor
You have: https://developer.apple.com/documentation/pdfkit
I just have three months learning experience in Swift, so please forgive my ignorance.
I am doing a Book reading app and populating the chapters using a json file.
The problem i am facing is :
1. This chapter contents can have sub headers or quotes in between them which are supposed to be in bold or some in italics. I am not sure how to identify these parts and display them in bold/italics.
I had two approaches to this:
1. Use just a UITextView to display chapter contents. In this case, my json looks like this :
"book": {
"name": "Fairy Tale,",
"chapters": [
{
"chapterNumber": 1,
"chapterName": "Tale First",
"chapterContents": "<\bold>This is a first heading.And it will be bold.Contents come here<\bold>.This will be plain text. Non bold.<\bold>This is a second heading.<\bold> And it will be bold.Contents come here.This will be plain text. Non bold."
}
]
}
Put some string like <\bold> and use it to split it. And then show the strings in bold for heading and non bold for the contents. But this does not look like a solution, and i am not sure, if i can split this up properly and also do this for all the 18 chapters.
Using a UITableViewCell and put UITextView within it. And pass an array of chapterContents with its heading and contents. So my json looks like this.
"book": {
"name": "Fairy Tales,",
"chapters": [
{
"chapterNumber": 1,
"chapterName": "Tale First",
"chapterContents": [
{
"contentHeader": "This is a first heading.And it will be bold.",
"contents": "Contents come here.This will be plain text. Non bold."
},
{
"contentHeader": "This is a second heading.And it will be bold.",
"contents": "Contents come here.This will be plain text. Non bold."
}
]
}
]
}
and then iterate over the chapterContents array, and put each one in one TableViewCell containing a UILabel for showing the contentHeader, and UITextView for showing the contents. But with this, i will have to remove the scroll since i want the chapters to scroll for the entire length of the screen and not limit to the cell height. And am not sure if this is how the book reading app should be done.
These both dont look like feasible solutions.
Could some one please help me to know
1. if there is some other component that supports this kind of display or a different solution that i can implement to figure out the bold and non bold parts.?
2. Or if using the UITextView inside a UITableViewCell is one of the ways of doing it.?
Thanks in advance. I am using Swift 2.
let json : NSString = <h1>Heading</h1><p><strong>Lorem Ipsum</strong>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<h1>Heading</h1><p><strong>Lorem Ipsum</strong> is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
let attrStr = try! NSAttributedString(
data: json.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!,
options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
documentAttributes: nil)
dispatch_async(dispatch_get_main_queue(), {
yourTextView.attributedText = attrStr
})
I'm into finding a way to generate Lorem ipsum in eclipse when creating views just for dummy texts. for example in Visual studio you can do it simply by typing lorem and press tab.
Is there any to do that in eclipse? any Idea?
In Android Studio, you can preview lorem ipsum TextViews with:
tools:text="#tools:sample/lorem/random"
You can also use this for Names, Cities, Zip codes, Avatars, and more.
see https://developer.android.com/studio/write/tool-attributes.html#toolssample_resources
I haven't encountered an Eclipse functionality to actually generate dummy text, but I do highly recommend this workaround (truth be told, I don't think you need different dummy text each time).
Create an Eclipe template. It's an xml file that looks like this:
<templates>
<template autoinsert="true" context="java" deleted="false" description="Dummy text" enabled="true" name="Lorem Ipsum">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</template>
</templates>
Go to Java -> Editor -> Templates and import the above file.
Now, when you write code and type lore (which represents the name attribute value of the template tag above), and hit CTRL+SPACE, then it will automatically insert the lorem ipsum text.
More Tips:
Add apostrophes to the ipsum text, so that it automatically generates a Java String
Add + signs to the ispum text, so that it breaks down the long string when inserted
Set the autoinsert attribute to false. Then you can see the ipsum description in the proposal
Set the name of the template to something like aaa_LoremIpsum. Then, in Eclipse, type aaa and press CTRL+SPACE. That way you can add many templates beginning with aaa, and select in Eclipse whichever you like.
I myself have templates for separating methods in a class. (e.g. aaa_1.StaticFields, aaa_2.InstanceFields, aaa_3.Constructors etc.)
They can help.
tools:text="#tools:sample/cities"
tools:text="#tools:sample/backgrounds/scenic"
tools:text= "#tools:sample/avatars"
tools:text="#tools:sample/full_names"
tools:text=”#tools:sample/lorem"
tools:text=”#tools:sample/lorem/random"
for other
I'm loading content to a textarea, which is then initialized as an instance of tiny mce. It works perfect until the textarea has only paragraph. When I try to load a paragraph with an image inside it, it works strange. All the content inside the original paragraph is moved to a new paragraph and the original is added empty. Why this is happening. Thanks in advance.
I'm trying to load following :-
<p id="paragraph-06C073B3-6BA7-AE52-7BFE-9CA282E448DC"
class="textElementClass"><div aria-disabled="true" style="position: relative;
z-index: auto;" class="draggableItem imageElement NestedImg ui-draggable-disabled
ui-state-disabled" id="Element-4C4AC020-0B32-99E9-356E-CCD6470E8294">
<img style="position: relative;" src="images/file-managements.png" class="ImageEdit
ui-draggable ui-draggable-disabled"
id="image-4C4AC020-0B32-99E9-356E-CCD6470E8294"></div>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
has been the industry's standard dummy text ever since the 1500s, when an unknown
printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting,
remaining essentially unchanged. It was popularised in the 1960s with the release of
Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p><div
style="" class="dropAfter ui-droppable"></div>
After loading it gets changed to :
<p id="paragraph-06C073B3-6BA7-AE52-7BFE-9CA282E448DC"
class="textElementClass"> </p>
<div id="Element-4C4AC020-0B32-99E9-356E-CCD6470E8294" class="draggableItem
imageElement NestedImg ui-draggable-disabled ui-state-disabled" style="position:
relative; z-index: auto;"><img id="image-4C4AC020-0B32-99E9-356E-CCD6470E8294"
class="ImageEdit ui-draggable ui-draggable-disabled" style="position: relative;"
src="images/file-managements.png" alt="" /></div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an
unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting,
remaining essentially unchanged. It was popularised in the 1960s with the release of
Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p> </p>
It might be because the p-tag is used as default wrapping element by tinymce leading to this wierd behavior.
EDIT: "/div>" is not a valid html tag. Try to verify the html you want to insert.
TinyMCE has a HTML "normalizer" engine that will rewrite your code on the fly. As I remember it, this is because some browsers add weird white space elements in content editable areas and other such and other differences.
You're not support to put a div tag (block level) in a p tag (block level). TinyMCE probably takes this into account. Use a styled span tag instead.
There's an init option to get TinyMCE not to normalize content but this is not recommended as some browsers might not render content correctly the way TinyMCE needs it.