Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 months ago.
Improve this question
I am trying to put a new image every time someone closes and reopens the app.
This is a sample view:
import SwiftUI
struct SwiftUIView: View {
var body: some View {
Image("PictureName")
}
}
struct SwiftUIiew_Previews: PreviewProvider {
static var previews: some View {
SwiftUIView()
}
}
create a constant that is an array of images.
let images: [String] = ["image1", "image2", "image3", "image4"]
Then when you call the constant inside Image modify it with random element
Image(images.randomElement()!)
im force unwrapping it which is for demo only and not recommended.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 24 days ago.
Improve this question
My goal is to make a fancy animation in SVG element provided by designer, while user activates and speaks in his microphone. Something similar you might have seen in chat apps like Telegram, Skype, WhatsApp etc.
Here is picture from designer (made in Figma).
Unfortunately, I couldn't find any similar solution on internet even though I was looking for it for hours ☹️. Any similar examples or at least direction to study would be highly appreciated.
I am working in Vue 3 if it matters.
I'm not sure if I understand correctly what needs to be done, but you can try the following:
Add two < img > tags to your template, one for each picture.
<template>
<img v-if="speaking" src="speaking.png" />
<img v-else src="not-speaking.png" />
</template>
Add a data property speaking to your component's data, and initialize it to false.
<script>
export default {
data() {
return {
speaking: false,
};
},
...
};
</script>
Use the analyser.getByteFrequencyData(dataArray) method to check if the user is speaking or not.
setInterval(() => {
analyser.getByteFrequencyData(dataArray);
if (dataArray[0] > 20) {
this.speaking = true;
} else {
this.speaking = false;
}
}, 50);
You can check this for more information: https://www.npmjs.com/package/vue-capture/v/0.1.3
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
For example, I want the user to favorite things and they can but the downside is when I change the icon to show that they've click on the button, all the slides' icons changes as well. How can I individualize each slide so when I do a if/else statement on the UI, it'll only effect that specific slide.
It's hard to help without looking at the actual code but to answer your question, you could try adding a selected column with boolean value in your firestore table so when a card is clicked, you can update the column value for that item to true and refresh the state so that only the card with true is changed leaving rest of the cards unchanged with selected as false.
Example psuedo code:
return FutureBuilder(
future: getDataFromFirestore(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Column(
children: List.generate(snapshot.data.length, (itemIndex) {
Macro macro = snapshot.data[itemIndex];
return Card(
child: ListTile(
title: Text(snapshot.data["title"]),
subtitle: Text(snapshot.data["subtitle"]),
trailing: IconButton(
icon: snapshot.data["selected"] ? Icons.check : Icons.add //If card is selected, display checked icon else display add icon
onPressed: () async {setState(() {}); //Refresh state}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have two components, parent and child.
In parent I have header.In children I have two views.
If one button in child is pressed then it will change to another view.
If it is another view I want to hide the header from parent
componentDidMount(){
document.getElementById("ID_NAME").innerHTML = <Text>hello world</Text>
}
render() {
return (
<Text id="ID_NAME"></Text>
)
}
I want to call that Text element and change its value
The element is in another component where props cannot be passed
When working with React / React Native you should forget everything (almost) you know about html / css.
This class will do what you want to achieve. You should read the React Native docs and tutorials
export default class App extends React.Component {
state = {
idName: '',
}
componentDidMount() {
this.setState({ idName: 'hello world' })
}
render() {
return (<Text>{this.state.idName}</Text>)
}
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am new to Telerik Kendo UI and currently working on a TreeView (http://demos.telerik.com/kendo-ui/treeview/index)
Basically it expands/collapses when I double click on it or when I click on triangle icon. My question is this: how can I change this behaviour to expand/collapse the tree node on a single click?
Thanks in advance.
Do it using jQuery. Here is a code assuming that kendoTreeView id is "treeview":
$("#treeview").on('click', '.k-in', function () {
var tree = $("#treeview").data('kendoTreeView');
var item = $(this).closest('.k-item');
if (item.attr('aria-expanded') === "true") {
tree.collapse(item);
}
else {
tree.expand(item);
}
});
Or even shorter:
$("#treeview").on("click", ".k-in", function (e) {
var tree = $("#treeview").data('kendoTreeView');
tree.toggle($(e.target).closest(".k-item"));
});
Working example: http://dojo.telerik.com/ESofU
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I need a button on addon bar and button on toolbar that redirect to some type of settings page(html,css,js) and this page can interact with main.js. Can it be done? If can, plz reccomend good tutorial.
Add button: use widget, ActionButton or ToggleButton.
Settings page(html,css,js):use page-mod.
Interact with main.js:use port or postMessage()
Here is an example:
main.js:
var pageMod = require("sdk/page-mod");
var widgets = require("sdk/widget");
var tabs = require("sdk/tabs");
const data = require("sdk/self").data;
var optionsPage = pageMod.PageMod({
include: data.url("options.html"),
contentScriptFile: data.url("options.js"),
onAttach: function(worker) {
worker.port.on("callMain",function(msg){
console.log("callMain: " + msg);
});
}
});
var widget = widgets.Widget({
id: "justForTest",
label: "justForTest",
contentURL: data.url("widget.png"),
onClick: function(){
tabs.open(data.url("options.html"));
}
});
options.js:
self.port.emit("callMain", "from options.js");