package com.example.punyaria;

import android.content.Context;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.List;

public class CustomAdapterWellness extends ArrayAdapter<String> {

    public CustomAdapterWellness(Context context, int resource, List<String> objects) {
        super(context, resource, objects);
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(getContext());
        View customView = inflater.inflate(R.layout.list_item_wellness, parent, false);

        TextView textViewPerasaan = customView.findViewById(R.id.textViewPerasaan);
        TextView textViewTanggal = customView.findViewById(R.id.textViewTanggal); // Add this line
        TextView textViewKeluhan = customView.findViewById(R.id.textViewKeluhan);

        String item = getItem(position);
        if (item != null) {
            String[] parts = item.split("\n");
            if (parts.length >= 3) {
                textViewPerasaan.setText(parts[0]);
                textViewTanggal.setText(parts[2]); // Set the text for tanggal
                textViewKeluhan.setText(parts[1]);
            }
        }

        // Set font size for TextViewTanggal
        textViewTanggal.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);

        return customView;
    }
}
