小编Ris*_*rdi的帖子

如何在 Jetpack Compose 中预览 LazyPagingItems/Paging 3 库

我认为标题说明了一切。

LazyPagingItems构造函数是内部的。我无法LazyPagingItems在 Preview Composable 中作为参数传递,更不用说传递示例数据了。但我想显示可组合项的预览,我应该怎么做?

@Composable
fun MainUi(users: LazyPagingItems<User>) {
    Scaffold {
        LazyColumn() {
            items(users) {
                // Rest of the code..
            }
        }
    }
}

@Preview
@Composable
fun Preview() {
    DefaultTheme {
        MainUi(users = ) // How to pass sample data here?
    }
}
Run Code Online (Sandbox Code Playgroud)

android-jetpack-compose android-jetpack-compose-list

18
推荐指数
1
解决办法
4759
查看次数

Jetpack Compose 相当于 @tools:sample/* 资源

在视图系统中我们可以用来@tools:sample/*显示占位符数据。

例子:

<ImageView
        android:layout_width="match_parent"
        android:layout_height="100dp"
        tools:src="@tools:sample/backgrounds/scenic" />
Run Code Online (Sandbox Code Playgroud)

使用这个Android Studio会显示一个随机的示例图像供我们预览。

我的问题是,我们如何在 Compose 中实现这一目标?

android-jetpack-compose

9
推荐指数
0
解决办法
562
查看次数

更改 Jetpack Compose 中的 android:windowBackground

我想使用 Jetpack Compose 实现启动屏幕。android:windowBackground在旧的 View 系统中,我们只需通过 XML更改主题即可。

如何在 Compose 中执行此操作?

android android-jetpack-compose

5
推荐指数
1
解决办法
2927
查看次数

使用 Firebase Cloud Functions 时 Nodemailer 查询 EREFUSED localhost

每当 Firebase 数据库中创建新订单时,我都会尝试向管理员帐户发送电子邮件。我为此使用 Cloud Functions 和 Nodemailer,但出现以下错误:

错误:queryA EREFUSED localhost at QueryReqWrap.onresolve [as oncomplete] (dns.js:213:19)

这是代码:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
const nodemailer = require('nodemailer');
admin.initializeApp();

/**
* Here we're using Gmail to send 
*/
let transporter = nodemailer.createTransport({
    service: 'smtp.gmail.com',
    port: 465,
    secure: true,
    auth: {
        user: 'myemail@gmail.com',
        pass: 'mypass'
    }
});

exports.sendMail = functions.database.ref('/Order/{orderId}').onCreate((snapshot, context) =>{
    const dest = 'destination@gmail.com';

    const mailOptions = {
        from: 'Risal Fajar <noreply@bukakata.com>',
        to: dest,
        subject: 'I\'M A PICKLE!!!',
        html: …
Run Code Online (Sandbox Code Playgroud)

node.js firebase nodemailer google-cloud-functions

3
推荐指数
1
解决办法
7954
查看次数