React Native - Position child view above parent's view sibling - react-native

I build a textinput like facebook's mentions. After typing # you get a list with different hashtags. I have two of them on one site, one for the title and one for the text.
The problem is, that the hashtag-list from the title is displayed below the text of the content. See Screenshot for that:
The list of hashtags is behind the lorem ipsum content
I tried using the zIndex but it does not have any effect here.
The hierachie is as follows:
View:
-- MentionsText Title
--- #List for Title
-- MentionsText Content
--- #List for Content
As you can see, the content is below the title in the hierachy. That positions it correctly on the screen, but displayes itself above the list of the title. Is there any way of accomplishing it with a smooth solution?

Try wrapping your blocs into views independently, don't use absolute position.
Btw if your list can grow without limit you may need a ScrollView or FlatList.

I found a solution that contains wrapping both textinput in one view, changing the order (content first, then title) and then setting flexDirection of the view to 'column-reverse'. That way the title is again on top and the z-index is now correctly set too. Just doesnt seem very nice, maybe someone got a tip to improve it. The code is the following (note that the MentionsTextInput contains the List as a child):
<View style={{flexDirection:'column-reverse'}}> //The newly added view
<MentionsTextInput //The content of the page
style={styles.inputContent}
placeholder={I18n.t("descriptionInput")}
value={this.state.description}/>
<MentionsTextInput //The title
style={styles.inputTitle}
placeholder={I18n.t("noteTitle")}
value={this.state.title}/>
</View>

Related

How do I resize an array of squished PyQt5 widgets? [duplicate]

I have a QScrollArea Widget, which starts empty;
It has a vertical layout, with a QGridLayout, and a vertical spacer to keep it at the top, and prevent it from stretching over the whole scroll area;
Elsewhere in the program, there is a QTextEdit, which when changed, has its contents scanned for "species" elements, and then they are added to the QGridLayout. Any species elements which have been removed are removed too. This bit works;
I have turned the vertical scrollbar on all the time, so that when it appears it does not sit on top of the other stuff in there. Note that the scroll bar is larger than the scroll box already though, despite not needing to be.
This is the problem. The scroll area seems to be preset, and i cannot change it. If i add more rows to the QGridLayout, the scroll area doesn't increase in size.
Instead, it stays the same size, and squeezes the QGridLayout, making it look ugly (at first);
And then after adding even more it becomes unusable;
Note that again, the scroll bar is still the same size as in previous images. The first two images are from Qt Designer, the subsequent 3 are from the program running.
If I resize the window so that the QScrollArea grows, then I see this:
Indicating that there's some layout inside the scroll area that is not resizing properly.
My question is; what do I need to do to make the scrollable area of the widget resize dynamically as I add and remove from the QGridLayout?
If you're coming here from Google and not having luck with the accepted answer, that's because you're missing the other secret invocation: QScrollArea::setWidget. You must create and explicitly identify a single widget which is to be scrolled. It's not enough to just add the item as a child! Adding multiple items directly to the ScrollArea will also not work.
This script demonstrates a simple working example of QScrollArea:
from PySide.QtGui import *
app = QApplication([])
scroll = QScrollArea()
scroll.setWidgetResizable(True) # CRITICAL
inner = QFrame(scroll)
inner.setLayout(QVBoxLayout())
scroll.setWidget(inner) # CRITICAL
for i in range(40):
b = QPushButton(inner)
b.setText(str(i))
inner.layout().addWidget(b)
scroll.show()
app.exec_()
The documentation provide an answer :
widgetResizable : bool
This property holds whether the scroll area should resize the view widget.
If this property is set to false (the default), the scroll area honors the size of its widget.
Set it to true.
Why don't you use a QListView for your rows, it will manage all the issues for you? Just make sure that after you add it you click on the Class (top right window of designer) and assign a layout or it wont expand properly.
I use a QLIstWidget inside a QScrollArea to make a scrollable image list
Try this for adding other objects to the list, this is how I add an image to the list.
QImage& qim = myclass.getQTImage();
QImage iconImage = copyImageToSquareRegion(qim, ui->display_image->palette().color(QWidget::backgroundRole()));
QListWidgetItem* pItem = new QListWidgetItem(QIcon(QPixmap::fromImage(iconImage)), NULL);
pItem->setData(Qt::UserRole, "thumb" + QString::number(ui->ImageThumbList->count())); // probably not necessary for you
QString strTooltip = "a tooltip"
pItem->setToolTip(strTooltip);
ui->ImageThumbList->addItem(pItem);
Update on Artfunkel's answer:
Here's a PySide6 demo that uses a "Populate" button to run the for loop adding items to the scroll area. Each button will also delete itself when clicked.
from PySide6.QtWidgets import *
app = QApplication([])
scroll = QScrollArea()
scroll.setWidgetResizable(True) # CRITICAL
inner = QFrame(scroll)
inner.setLayout(QVBoxLayout())
scroll.setWidget(inner) # CRITICAL
def on_remove_widget(button):
button.deleteLater()
def populate():
for i in range(40):
b = QPushButton(inner)
b.setText(str(i))
b.clicked.connect(b.deleteLater)
inner.layout().addWidget(b)
b = QPushButton(inner)
b.setText("Populate")
b.clicked.connect(populate)
inner.layout().addWidget(b)
scroll.show()
app.exec()

I need to display related product carousel in my sidebar

I have added the code remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products',20); and add inside the text editor the shortcode [related_products per_page="3" columns="1"], but it is displaying unproperly. Is there is any solution
Displaying Like this:
https://im4.ezgif.com/tmp/ezgif-4-233a5a5d74.webp
Does anybody have the solution??

Titanium get current view on scrollableView and add an item

I have a scrollableView with several views inside and I'd like to add item to some of these view if they meet a certain criteria, like if they have data attached or not. Also I'm using Alloy, here's my markup
<ScrollableView id="scrollableView">
<View id="view" class='coolView'></View>
...
</ScrollableView>
To know if there are data attached I check the currentPage attribute like so:
function updateCurrentView(e) {
currentView = e.currentPage;
}
But I have no idea how to add an item to the current View.
Edit: To add some clarification, I have a label which when clicked allow me to choose two currencies, when chosen these currency pairs are saved in the database and should be displayed instead of the label. So my guess was to check whether the current view has currency pair saved.
There are 2 things to take care of here:
1.Whenever a currency is selected,immediately label on that particular view will change.
2.Whenever the scrollableView is loaded,it must always refer to the database if a currency is selected.
First one can be done as:
1.Get the instance of scrollableView using the getView method of alloy controller.Pass the id of the scrollableView to it.Lets call it myScrollableView.Refer this for more info.
http://docs.appcelerator.com/titanium/latest/#!/api/Alloy.Controller
2.Use var currentView=myScrollableView.getCurrentPage() to the get the current page which will be a number.
3.Now use the scrollableView instance to get all the views.
var viewArray=myScrollableView.getViews();
4.viewArray[currentView] will give you the view of current page.After you have got the view you can change the desired label using:
viewArray[currentView].children[positionOfTheView]
The "positionOfTheView" can be obtained by printing the viewArray[i].children array using Ti.API.info.
Second thing can be accomplished as follows:
1.Get the instance of scrollableView using the getView method of alloy controller.Pass the id of the scrollableView to it.Lets call it myScrollableView.Refer this for more info.
http://docs.appcelerator.com/titanium/latest/#!/api/Alloy.Controller
2.Now use the scrollableView instance to get all the views.
var viewArray=myScrollableView.getViews();
3.This is a JavaScript array of all the views in the scrollableView. Now iterate through this array and according to the data in the database,change the concerned view using:
viewArray[i].children[positionOfTheView]
The "positionOfTheView" can be obtained by printing the viewArray[i].children array using Ti.API.info.

How to stretch inline frame size in panel stretch layout in ADF?

I have .jsff page that contain command button and inline frame. What I want to do is, I want to make command button remain static at the same place and only inline frame can move when scroll the page.
Currently what I do is I set some panel stretch layout(StyleClass:AFStetchWidth). I put the command button at the top. Inline frame in scroll panel group at the center.
Here is my structure:
af:panelStetchLayout(StyleClass:AFStretchWidth)
>
Panel Stretch Layout facets
bottom
center
af:panelGroupLayout-scroll
af:inlineFrame (StyleClass:AFStretchWidth)
end
start
top
af:panelGroupLayout-horizontal
af:commandButton-back
When I run this page: command button remain static at the top. This is correct, but the size of the inline frame is small. Is there a way to make an inline frame to be stretch?
set the (StyleClass:AFStretchWidth) on the af:panelGroupLayout-scroll.
Did you try putting this attribute :
sizing="preferred"
I have used it and it works pretty well inside panel stretch layout.
just i solve it as following:
<af:panelGroupLayout id="pgl1" halign="center">
<af:inlineFrame id="if1" source="/index.html" styleClass="AFStretchWidth" inlineStyle="height:100%;"/>
</af:panelGroupLayout>
inlineStyle="height:100%;"
on default af:panelGroupLayout
thats all.
I was getting the same issue. Here I have solved it as below:
I have used panel splitter for inline frame.
<af:panelSplitter styleClass="AFStretchWidth" inlineStyle="height:500px;" id="ps3" dimensionsFrom="parent"
positionedFromEnd="false">
<f:facet name="first">
<af:panelGroupLayout id="pgl11" >
<af:inlineFrame styleClass="AFStretchWidth" partialTriggers="cb3" source="#{pdfHandler.servletString}"
id="if1" visible="true" binding="#{pdfHandler.inLineFrame}" shortDesc=" "
inlineStyle="height:500px;"/>
</af:panelGroupLayout>
</f:facet>
Here as shown above,
I have added inlineStyle for height in both panelSplitter and in inlineFrame.
Added dimensionFrom for panelSplitter as 'parent'
Surround inlineFrame with panelGroupLayout.
With this, It worked for me.

Use Dojo Drag and Drop together with Dojo Moveable

I'm using Dojo.dnd to transfer items between to areas. The problem is: the items will snap into place once I drop them, but I'd like to have them stay where I drop them, but only for one area.
Here's a little code to explain this better:
<div id="dropZone" class="dropZone">
<div id="itemNodes"></div>
<div id="targetZone" dojoType="dojo.dnd.Source"></div>
</div>
"dropZone" is a DIV that contains two dojo.dnd.Source-areas, "itemNodes" (created programmatically) and "targetZone". Items (DIVs with images) should be dragged from a simple list out of "itemNodes" into "targetZone" and stay where they are dropped. As soon as they are dragged out of "targetZone" they should snap back to the list inside "itemNodes".
Here's the code I use to create the items:
var nodelist = new dojo.dnd.Source("itemNodes");
{Smarty-Loop}
nodelist.insertNodes(false, ['<img class="dragItem" src="{$items->info.itemtext}" alt="{$items->info.itemtext}" border="0" />']);
{/Smarty-Loop}
But this way I just have two lists of items, the items dropped into "targetZone" won't stay where I dropped them. I've tried a loop dojo.query(".dojoDndItem").forEach(function(node) to grab all items and change them to a "moveable"-type:
using dojo.dnd.move.constrainedMoveable will change the items so they can always be moved around (even in "itemNodes")
using dojo.dnd.move.boxConstrainedMoveable and defining the "box" to the borders of "targetZone" makes it possible to just move the items around inside "targetZone", but as soon as I drop them, I can't grab and move them back out. (Strange: dojo.connect(node, "onMoved" doesn't work here, the even won't fire, no matter what.)
So here's the question: is it possible to create two dnd.Sources where I can move items back and forth and let the items be "moveable" only in one of the sources?Or is there a workaround like making the items moveable and if they're not dropped into "targetZone" they'll be moved back to the list in "itemNodes" automatically?
Once the page is submitted, I have to save the position of every item that has been placed into "targetZone". (The next step will be positioning the items inside "targetZone" on page load if the grid has already been filled before, but I'd be happy to just get the thing working in the first place.)
Any hint is appreciated.
Greetings, Select0r
There is no direct support for such features. It can be done with a custom code, e.g., by subclassing a Source and overriding its insertNodes().
Here's a quick workaround to get this working:
I ended up using only one DIV which is a dojo.dnd.Source and contains the items that should be dropped into a "dropZone" and moved around in it while snapping back to the item-list when placed outside the dropZone.
All items are a dojo.dnd.move.parentConstrainedMoveable to make them movable in the originating DIV. Connecting to onMoveStop will give me the opportunity to decide whether the "drop" has occured in the dropZone or somewhere else.
if (coordX >= (dropCoords.l + dropAreaX) &&
coordX <= (dropCoords.l + dropAreaX + dropAreaW) &&
coordY >= (dropCoords.t + dropAreaY) &&
coordY <= (dropCoords.t + dropAreaY + dropAreaH))
{
// OK!
}
else
{
// outside, snap back to list
}
dropAreaX and dropAreaY contain the coordinates where the dropZone starts, dropAreaW and dropAreaH contain its width and height.
If "OK!", the items will be saved into an array, so I know which items have been dropped. Otherwise the item will be removed from that array (if it's in there) and the item will be placed back into the list (via CSS "left: 0"). The number of elements in the array will tell me how many elements are left in the list, so I can "stack" them in a loop using "top: numberOfElement * heightOfElement px").
There's more to it as I need the items coordinates written to hidden fields, but I guess this should get anybody who's working on a similar problem on the right track.